-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawReads.py
More file actions
32 lines (28 loc) · 1.1 KB
/
RawReads.py
File metadata and controls
32 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os,re,glob,commands
listOfFiles = glob.glob('*.gz')
print listOfFiles
SampleID = list(listOfFiles)
i=0
for item in listOfFiles:
SampleID[i] = re.split('\.|_', str(item))[0]
i = i + 1
prefixSet=list(set(SampleID))
prefixSet.sort()
print prefixSet
for prefix in prefixSet:
result = commands.getoutput('zcat '+ prefix + '_1.fq.gz | wc -l')
numreads = int(result)/4.0
unzip1 = 'gunzip -d -c -f -k '+ prefix + '*paired* > ' + prefix + '.paired.bowtie'
unzip2 = 'gunzip -d -c -f -k '+ prefix + '*_1*.singles* > ' + prefix + '_1.singles.bowtie'
unzip3 = 'gunzip -d -c -f -k '+ prefix + '*_2*.singles* > ' + prefix + '_2.singles.bowtie'
catcmd = 'cat ' + prefix + '.paired.bowtie ' + prefix + '_1.singles.bowtie ' + prefix + '_2.singles.bowtie > ' + prefix + '.bowtie'
zipcmd = 'gzip -f -c -9 ' + prefix + '.bowtie > ' + prefix + '.bowtie.gz'
rmcmd = 'rm ' + prefix + "*.bowtie"
mvcmd = 'mv ' + prefix + '.bowtie.gz Merged'
os.system(unzip1)
os.system(unzip2)
os.system(unzip3)
os.system(catcmd)
os.system(zipcmd)
os.system(rmcmd)
os.system(mvcmd)