-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_seq2.py
More file actions
32 lines (25 loc) · 757 Bytes
/
Copy pathfind_seq2.py
File metadata and controls
32 lines (25 loc) · 757 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/env python
#synopsis : find_seq <list.txt> <fasta.txt> <output.txt>
#find sequences of genes in list.txt from fasta.txt and print to output.txt
import sys
#import re
f1 = open(sys.argv[1], 'r')
contigSet = set();
for line in f1:
contigSet.add(line)
# Demanded contigs have been collected in contigSet
f2 = open(sys.argv[2], 'r')
fout = open(sys.argv[3], 'w')
collect = False
for line in f2:
if line[0] == '>':
tok = line[1:].split()
if (tok[0]+'\n' in contigSet) or (tok[0] in contigSet) or (line[1:-1] in contigSet) or (line[1:] in contigSet):
#if (line[1:] in contigSet):
collect = True
fout.write(line);
else:
collect = False
else:
if collect:
fout.write(line);