forked from brianpenghe/fastq-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixFastq.py
43 lines (33 loc) · 1.02 KB
/
fixFastq.py
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
33
34
35
36
37
38
39
40
41
42
##################################
# #
# Last modified 11/28/2011 #
# #
# Georgi Marinov #
# #
##################################
import sys
try:
import psyco
psyco.full()
except:
pass
def main(argv):
if len(argv) < 2:
print 'usage: python %s inputfilename outfilename' % argv[0]
print ' this script will replace all intervals in fastq ID lines with an _ character so that IDs are not truncated by bowtie or other programs'
sys.exit(1)
inputfilename = argv[1]
outputfilename = argv[2]
outfile = open(outputfilename, 'w')
lineslist = open(inputfilename)
i=0
for line in lineslist:
i+=1
if i % 10000000 == 0:
print str(i/1000000) + 'M lines processed'
if i % 4 == 1 and line.startswith('@'):
line=line.replace(' ','_')
outfile.write(line)
outfile.close()
if __name__ == '__main__':
main(sys.argv)