-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREVP.py
36 lines (28 loc) · 856 Bytes
/
REVP.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
#!/usr/bin/env python
# Locating Restriction Sites
from Bio import SeqIO
def switch(str):
str = str[::-1]
switch_str = ''
for i in range(len(str)):
if str[i] == 'A':
switch_str += 'T'
elif str[i] == 'T':
switch_str += 'A'
elif str[i] == 'G':
switch_str += 'C'
elif str[i] == 'C':
switch_str += 'G'
return switch_str
def palindrome(str):
for i in range(len(str)):
for j in range(4,13,1):
if str[i:i+j] == switch(str[i:i+j]) and (i+j <= len(str)):
print(i+1, j)
seq_name, seq_string = [], []
with open ('data/rosalind_revp.txt','r') as f:
for seq_record in SeqIO.parse(f,'fasta'):
seq_name.append(str(seq_record.name))
seq_string.append(str(seq_record.seq))
seq = seq_string[0]
palindrome(seq)