-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilterFasta.py
26 lines (23 loc) · 869 Bytes
/
FilterFasta.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
import sys
def FilterFasta(inFile,outFile,l):
dest=open(outFile,"w")
seq=""
with open(inFile) as source:
for line in source:
if line.startswith(">"):
if seq!="":
if ("*" not in seq) and len(seq)>=int(l):
dest.write(header+"\n")
tmpList=[seq[i:i+60] for i in range(0,len(seq),60)]
dest.write("\n".join(tmpList)+"\n")
del tmpList[:]
seq=""
header=line.strip()
else:
seq+=line.strip()
if ("*" not in seq) and len(seq)>=int(l):
dest.write(header+"\n")
tmpList=[seq[i:i+60] for i in range(0,len(seq),60)]
dest.write("\n".join(tmpList)+"\n")
if __name__=="__main__":
FilterFasta(sys.argv[1],sys.argv[2],sys.argv[3])