forked from mengqvist/DNApy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patholigo_localizer.py
More file actions
71 lines (62 loc) · 2.43 KB
/
Copy patholigo_localizer.py
File metadata and controls
71 lines (62 loc) · 2.43 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
##################################################################################
# An oligo or motif finder written by Andrea Cabibbo # ###### #
# Feel free to use/modify/redistribute the code # # # #
# If you use significant parts of this code please preserve # # # #
# this header. ####### # #
# If you find bugs or have suggestions, please contact # # # #
# the author at andrea.cabibbo@uniroma2.it # # ###### #
# The tool is available online at #
# http://www.cellbiol.com/scripts/oligo/oligo_motif_sequence_finder.php #
##################################################################################
#script from above source modified by Martin Engqvist
import re
import string
def re_const(oligo):
'''This is the actual search function'''
oligo=oligo.upper()
re_out=[]
for char in oligo:
if char=='G':
re_out.append('[GRSKVDBXN]')
elif char=='A':
re_out.append('[AMRWVHDXN]')
elif char=='T':
re_out.append('[TWYKHDBXN]')
elif char=='C':
re_out.append('[CMSVHBXN]')
elif char=='M':
re_out.append('[MACVHXN]')
elif char=='R':
re_out.append('[RAGVDXN]')
elif char=='W':
re_out.append('[WATHDXN]')
elif char=='S':
re_out.append('[SCGVBXN]')
elif char=='Y':
re_out.append('[YCTHBXN]')
elif char=='K':
re_out.append('[KGTDBXN]')
elif char=='V':
re_out.append('[VACGXNMRS]')
elif char=='H':
re_out.append('[HACTXNMWY]')
elif char=='D':
re_out.append('[DAGTXNRWK]')
elif char=='B':
re_out.append('[BCGTXNSYK]')
elif char=='X':
re_out.append('[XNMRWSYKVHDBGATC]')
elif char=='N':
re_out.append('[NXMRWSYKVHDBGATC]')
re_out=string.join(re_out,'')
re_out="(?=(%s))" % re_out
re_out_comp=re.compile(re_out,re.IGNORECASE)
return re_out_comp
def match_oligo(seq,oligo,mismatches=0):
'''Function for searching for a certain oligo'''
re_oligo=re_const(oligo)
L_out=[]
for match in re_oligo.finditer(seq):
L_out.append([match.start()+1, match.end()+len(match.group(1))])
return L_out