-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq44.py
More file actions
39 lines (32 loc) · 1.04 KB
/
q44.py
File metadata and controls
39 lines (32 loc) · 1.04 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
from Bio.Seq import Seq #Using Biopython to find reverse complement.
from Bio.Alphabet import generic_dna
f = open("rosalind_revp.txt",'r') #To extract input from the file
inputs1 = f.read()
#print inputs
seq=inputs1.strip().split('>')
inputv = []
for s in seq:
if(s!=""):
strings=s.split()
part1=strings[0]
part2=''.join(strings[1:])
inputv.append(part2)
#print inputv
string = inputv[0]
#print string
result = []
position1 = []
position2 = []
#print len(string)
for j in range(4, 13): #Determing the palindrome sequences in the given input
for i in range(0, len(string)-j+1):
#print string[i:i+j]
s = string[i:i + j]
my_dna = Seq(s,generic_dna)
if my_dna == my_dna.reverse_complement():
position1.append(i+1)
position2.append(j)
result.append(my_dna)
#print result
for i in range(len(position1)): #printing the output in the specifed format.
print position1[i],position2[i]