-
Notifications
You must be signed in to change notification settings - Fork 0
/
residue_library.py
37 lines (33 loc) · 1 KB
/
residue_library.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
"""
Residue library management
Attypes and partial charges
data from CMIP reslib formatted file
"""
import sys
class ResiduesDataLib():
def __init__(self, fname):
self.residue_data = {}
try:
fh = open(fname, "r")
except OSError:
print("#ERROR while loading library file (", fname, ")")
sys.exit(2)
for line in fh:
if line[0] == '#':
continue
data = line.split()
r = Residue(data)
self.residue_data[r.id] = r
self.nres = len(self.residue_data)
def get_params(self, resid, atid):
atom_id = resid + ':' + atid
if atom_id in self.residue_data:
return self.residue_data[atom_id]
else:
print("WARNING: atom not found in library (", atom_id, ')')
return None
class Residue():
def __init__(self, data):
self .id = data[0] + ':' + data[1]
self.at_type = data[2]
self.charge = float(data[3])