-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq49.py
More file actions
29 lines (21 loc) · 766 Bytes
/
q49.py
File metadata and controls
29 lines (21 loc) · 766 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
from collections import deque #Using collections to rotate strings.
f = open("rosalind_ba9i.txt","r") #Rotating the string.
inputv = f.read().strip()
midreslist = []
midreslist.append(inputv)
def rotation(seq): #rotation of characters being performed.
d = deque(seq)
rlist = []
for i in range(0,len(d)):
rlist.append(''.join(map(d.rotate(-1),d)))
return (rlist)
r = rotation(inputv)
for i in range(0,len(r)-1):
midreslist.append(r[i])
#print midreslist
midreslist.sort() #sorting.
#print midreslist
result = ""
for i in range(0,len(midreslist)): #determing the Burrows-Wheeler Transform.
result = result + midreslist[i][-1:]
print result