forked from carden24/Bioinformatics_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter_fasta.py
More file actions
35 lines (26 loc) · 697 Bytes
/
filter_fasta.py
File metadata and controls
35 lines (26 loc) · 697 Bytes
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
#!/usr/bin/python
#usage
#python rename.fasta-to-fasta.py <filein> > <fileout>
import sys
import Bio
from Bio import SeqIO
filein=open(sys.argv[1],'rb')
fileout=open(sys.argv[2], 'w')
for seq_record in SeqIO.parse(filein, format="fasta"):
line=seq_record.description
# print line
line=line.split('#')
# print line
partial_info=line[4]
# print partial_info
partial=partial_info.split(';')
# print partial
if partial[1]=='partial=00':
fileout.write('>%s %s\n%s\n' %(seq_record.id, seq_record.description, seq_record.seq))
# print 'complete'
else:
continue
# print name
# print '>%s\n%s' % (name, seq_record.seq)
filein.close()
fileout.close()