-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstar2sparky.py
executable file
·70 lines (61 loc) · 1.57 KB
/
star2sparky.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
#!/usr/bin/python
"""
read an nmrstar 2.1 file and produce a sparky HSQC peaklist
star2sparky.py input.star > output.list
"""
from sys import argv
def isfloat(numstring):
if '.' in numstring and numstring.replace('.','',1).isdigit():
return True
else:
return False
AA = {}
AA["ALA"] = "A"
AA["ARG"] = "R"
AA["ASN"] = "N"
AA["ASP"] = "D"
AA["CYS"] = "C"
AA["GLN"] = "Q"
AA["GLU"] = "E"
AA["GLY"] = "G"
AA["HIS"] = "H"
AA["ILE"] = "I"
AA["LEU"] = "L"
AA["LYS"] = "K"
AA["MET"] = "M"
AA["PHE"] = "F"
AA["PRO"] = "P"
AA["SER"] = "S"
AA["THR"] = "T"
AA["TRP"] = "W"
AA["TYR"] = "Y"
AA["VAL"] = "V"
if len(argv) != 2:
print "Usage:"
print "star2sparky.py input.star > output.list"
infile = argv[1]
openfile = open(infile,'r')
filelines = openfile.readlines()
openfile.close()
Nshifts = {}
Hshifts = {}
residues = {}
for line in filelines:
columns = line.split()
if len(columns) == 9:
atno = columns[0]
resno = columns[1]
resname = columns[3]
atname = columns[4]
shift = columns[6]
if atno.isdigit() and resno.isdigit() and isfloat(shift) and resname in AA.keys():
if atname == "H" or atname == "N":
if resno not in residues.keys():
residues[resno]=AA[resname]
if atname == "N":
Nshifts[resno]=shift
elif atname == "H":
Hshifts[resno]=shift
for res in residues.keys():
if res in Nshifts.keys() and res in Hshifts.keys():
print residues[res]+res+'N-H '+Nshifts[res]+' '+Hshifts[res]