forked from carlcward/sep-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_to_fa.py
More file actions
26 lines (23 loc) · 811 Bytes
/
list_to_fa.py
File metadata and controls
26 lines (23 loc) · 811 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
#converts a line delimited list of sequences to a fasta with the sequence being the description
import sys
import argparse
def list_to_fa_string(seqs):
out =''
for seq in seqs:
out += '>' + seq + '\n'
out += seq + '\n'
return out
if __name__ == '__main__':
parser = argparse.ArgumentParser("Takes a line deliminted list and converts it to FASTA")
parser.add_argument("in_file",type=str)
parser.add_argument("out_file",type=str)
args = parser.parse_args()
in_file = open(args.in_file, "r")
out_file = open(args.out_file, "w")
#delchars = ''.join(c for c in map(chr, range(256)) if not c.isalpha())
for line in in_file:
line = line.strip()
if line != '':
clean = filter(str.isalpha,line)#line.translate(None, delchars)
out_file.write(">" + clean + "\n")
out_file.write(clean + "\n")