-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakeFusionTranscripts.py
49 lines (32 loc) · 1.18 KB
/
MakeFusionTranscripts.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
41
42
43
44
45
46
47
48
49
import sys
class exon_seq_cont(object):
def __init__(self, filename):
self._seq_dict = {}
current_id = ""
current_seq = ""
for line in file(filename):
if line[0] == '>':
if current_id:
self._seq_dict[current_id] = current_seq
current_id = line.strip()[1:]
current_seq = ""
else:
current_seq += line.strip()
self._seq_dict[current_id] = current_seq
def getseq(self, sid):
return self._seq_dict[sid]
def main(exon_seq_file, fusion_exons_file):
esq = exon_seq_cont(exon_seq_file)
outf = open(fusion_exons_file + '.seqs', 'w')
count = 0
for line in file(fusion_exons_file):
seq = ""
ls = line.strip().split('\t')
for exon in ls:
seq += esq.getseq(exon)
outf.write('>Fusion' + str(count) +'|Fusion' + str(count) +'|fusion|fusions|0|100|1\n')
outf.write(seq)
outf.write('\n')
count += 1
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2])