-
Notifications
You must be signed in to change notification settings - Fork 2
/
start_sequence_finder.py
executable file
·72 lines (63 loc) · 1.49 KB
/
start_sequence_finder.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
#!/usr/bin/python
# Usage: ./start_sequence_finder.py [istable|eris] [json-file.json]
#
import json,sys
jfile_name = ""
def notAmino (s):
if "Sequence as provided" in s:
return True
return False
def getNum (s):
len_res = 3
num = -1
while (len_res>=1):
try:
num = int(s[4:4+len_res])
#print num
return num
except:
pass
#print "No num"
len_res = len_res - 1
return num
def readFile ():
global jfile_name
jfile = open (jfile_name, 'r');
data = json.load (jfile)
chainid = "D"
rawsequence = data["byChain"][chainid]["img"]["mapData"]["sequence"]
sequence = []
#print "sequence length:",len(sequence)
iter_num = 0
for amino in sequence:
desc = amino["t"]
if notAmino (desc):
continue
num = getNum (desc)
if num is not -1:
#print amino
return num-iter_num, num
break
iter_num = iter_num + 1
def getStartIstable ():
start, latestart = readFile ()
return start
def getStartEris ():
start, latestart = readFile ()
return latestart
if __name__=='__main__':
try:
try:
jfile_name = sys.argv [2]
except IndexError:
jfile_name = "2OCJ.json"
if sys.argv[1] == 'istable':
print getStartIstable ()
elif sys.argv[1] == 'eris':
print getStartEris ()
else:
print "Usage: ./start_sequence_finder.py [istable|eris] [json-file.json]"
except IndexError:
print getStartIstable ()
#print 'Istable', getStartIstable ()
#print 'Eris', getStartEris ()