-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathburrowsReconstruct.py
79 lines (61 loc) · 1.22 KB
/
burrowsReconstruct.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
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
71
72
73
74
75
76
77
78
79
import sys
def burrowsRe(text):
lastColumn = []
T = 0
C = 0
A = 0
G = 0
for letter in text:
if letter == 'T':
lastColumn.append(letter + str(T))
T +=1
elif letter == 'C':
lastColumn.append(letter + str(C))
C +=1
elif letter == 'G':
lastColumn.append(letter + str(G))
G +=1
elif letter == 'A':
lastColumn.append(letter + str(A))
A +=1
else:
lastColumn.append(letter + '0')
array = []
for letter in text:
array.append(letter)
array.sort()
firstColumn = []
T = 0
C = 0
A = 0
G = 0
for letter in array:
if letter == 'T':
firstColumn.append(letter + str(T))
T +=1
elif letter == 'C':
firstColumn.append(letter + str(C))
C +=1
elif letter == 'G':
firstColumn.append(letter + str(G))
G +=1
elif letter == 'A':
firstColumn.append(letter + str(A))
A +=1
else:
firstColumn.append(letter + '0')
relation = dict()
for i in range(len(text)):
relation[lastColumn[i]] = firstColumn[i]
word = ''
node = lastColumn[0]
for i in range(len(text)):
node = relation[node]
word = word + node[0]
word = word[1:] + word[0]
print word
filename = sys.argv[1]
file = open(filename, 'r')
data = file.read().splitlines()
string1 = data[0]
burrowsRe(string1)