forked from fjruizruano/ngs-protocols
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch_issr_2nt.py
More file actions
executable file
·49 lines (39 loc) · 989 Bytes
/
search_issr_2nt.py
File metadata and controls
executable file
·49 lines (39 loc) · 989 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python
from Bio import SeqIO
from Bio.Seq import Seq
import sys
try:
secu = sys.argv[1]
except:
secu = raw_input("Introduce fasta file: ")
try:
ssrs = sys.argv[2]
except:
ssrs = raw_input("Introduce Meglecz's script .seq file: ")
secu = SeqIO.parse(open(secu),"fasta")
ssrs = open(ssrs).readlines()
di = {}
i = 0
for s in secu:
i += 1
line = ssrs[i]
line = line.split(";")
if len(line) > 4:
motif_len = len(line[3][:-1])
motif_start = int(line[4])
motif = str(s.seq)
motif = motif[motif_start-3:motif_start+motif_len-1]
motif = motif[::-1]
motif_r = Seq(motif)
motif_r = str(motif_r.reverse_complement())
motif_r = motif_r[::-1]
if motif in di:
di[motif] += 1
elif motif_r in di:
di[motif_r] += 1
else:
di[motif] = 1
w = open("output.txt","w")
for el in di:
w.write("%s\t%s\n" % (el, str(di[el])))
w.close()