-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtrimFastq.py
executable file
·40 lines (30 loc) · 959 Bytes
/
trimFastq.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
#!/usr/bin/env python
"""
Trim length of fastq reads
"""
import sys, argparse
__author__ = "Colby Chiang (chiang@chgr.mgh.harvard.edu)"
__version__ = "$Revision: 0.0.1 $"
__date__ = "$Date: 2010/11/10 13:25 $"
parser = argparse.ArgumentParser(description='Trim length of fastq reads')
parser.add_argument('-i', '--input', type=file, help='Input fastq file')
parser.add_argument('-s', '--softclip', action='store_true', help='Soft clip trailing bases instead of removing them.')
parser.add_argument('-l', '--length', type=int, help='Bases to trim to')
args = parser.parse_args()
fqIn = args.input
length = args.length
softClip = args.softclip
if fqIn == None:
fqIn = sys.stdin
lineNumber = 0
for line in fqIn:
line = line.rstrip()
lineNumber += 1
if not softClip:
if lineNumber % 2 == 0:
print line[0:length]
else: print line
elif softClip:
if lineNumber % 4 == 0:
print line[0:length] + "#"*(len(line)-length)
else: print line