Commit d60306af by Peter Eastman

Use MODRES records to identify modified residues

parent a22bf8e7
...@@ -262,7 +262,19 @@ class PDBFixer(object): ...@@ -262,7 +262,19 @@ class PDBFixer(object):
self.structureChains = [self.structureChains[i] for i in range(len(self.structureChains)) if i not in chainIndices] self.structureChains = [self.structureChains[i] for i in range(len(self.structureChains)) if i not in chainIndices]
def findNonstandardResidues(self): def findNonstandardResidues(self):
self.nonstandardResidues = [(r, substitutions[r.name]) for r in self.topology.residues() if r.name in substitutions] # First find residues based on our table of standard substitutions.
nonstandard = dict((r, substitutions[r.name]) for r in self.topology.residues() if r.name in substitutions)
# Now add ones based on MODRES records.
modres = dict(((m.chain_id, m.number, m.residue_name), m.standard_name) for m in self.structure.modified_residues)
for structChain, topChain in zip(self.structureChains, self.topology.chains()):
for structResidue, topResidue in zip(structChain.iter_residues(), topChain.residues()):
key = (structChain.chain_id, structResidue.number, structResidue.name)
if key in modres:
nonstandard[topResidue] = modres[key]
self.nonstandardResidues = [(r, nonstandard[r]) for r in sorted(nonstandard, key=lambda r: r.index)]
def replaceNonstandardResidues(self): def replaceNonstandardResidues(self):
if len(self.nonstandardResidues) > 0: if len(self.nonstandardResidues) > 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment