|
@@ -32,7 +32,8 @@ class PDBFile:
|
32
|
32
|
|
33
|
33
|
def getAtoms(self):
|
34
|
34
|
self.ATOMS = []
|
35
|
|
-
|
|
35
|
+ self.RESIDUES = []
|
|
36
|
+ tempAtoms = []
|
36
|
37
|
for line in self.rawLines:
|
37
|
38
|
if line.startswith("ATOM" or "HETATM"):
|
38
|
39
|
atom = Atom(ATOM_ID = int(line[6:11].strip()),
|
|
@@ -50,8 +51,17 @@ class PDBFile:
|
50
|
51
|
ELEM_SYMBOL = line[76:78].strip(),
|
51
|
52
|
ATOM_CHARGE = line[78:80].strip())
|
52
|
53
|
self.ATOMS.append(atom)
|
53
|
|
-
|
54
|
|
-
|
|
54
|
+ # get the current indice of atom
|
|
55
|
+ i = self.ATOMS.index(atom)
|
|
56
|
+ # if this is a brand new residue
|
|
57
|
+ if(len(self.ATOMS)>1
|
|
58
|
+ and atom.RES_SEQ_NB != self.ATOMS[i-1].RES_SEQ_NB):
|
|
59
|
+ self.RESIDUES.append(Residue(tempAtoms))
|
|
60
|
+ tempAtoms=[]
|
|
61
|
+ tempAtoms.append(atom)
|
|
62
|
+ # last residue
|
|
63
|
+ self.RESIDUES.append(Residue(tempAtoms))
|
|
64
|
+
|
55
|
65
|
def __init__(self, filename):
|
56
|
66
|
self.rawLines = self.getContent(filename)
|
57
|
67
|
self.Metadata = self.getHeader()
|
|
@@ -66,3 +76,4 @@ if __name__ == "__main__":
|
66
|
76
|
"call structure and parameters.")
|
67
|
77
|
else:
|
68
|
78
|
pdbFile = PDBFile(sys.argv[1])
|
|
79
|
+ print(pdbFile.RESIDUES[0].ATOMS["N"].COORD_X)
|