Commit dd432501 authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Fix omitted construction of bondedToAtom

parent a773f1c7
...@@ -569,13 +569,34 @@ class ForceField(object): ...@@ -569,13 +569,34 @@ class ForceField(object):
break break
return [template, matches] return [template, matches]
def _buildBondedToAtomList(self, topology):
"""Build a list of which atom indices are bonded to each atom.
Parameters
----------
topology : Topology
The Topology whose bonds are to be indexed.
Returns
-------
bondedToAtom : list of set of int
bondedToAtom[index] is the set of atom indices bonded to atom `index`
"""
bondedToAtom = []
for atom in topology.atoms():
bondedToAtom.append(set())
for bond in topology.bonds():
bondedToAtom[bond.atom1.index].add(bond.atom2.index)
bondedToAtom[bond.atom2.index].add(bond.atom1.index)
def getUnmatchedResidues(self, topology): def getUnmatchedResidues(self, topology):
"""Return a list of Residue objects from specified topology for which no forcefield templates are available. """Return a list of Residue objects from specified topology for which no forcefield templates are available.
Parameters Parameters
---------- ----------
topology : Topology topology : Topology
The Topology for which to create a System The Topology whose residues are to be checked against the forcefield residue templates.
Returns Returns
------- -------
...@@ -586,6 +607,7 @@ class ForceField(object): ...@@ -586,6 +607,7 @@ class ForceField(object):
This method may be of use in generating missing residue templates or diagnosing parameterization failures. This method may be of use in generating missing residue templates or diagnosing parameterization failures.
""" """
# Find the template matching each residue, compiling a list of residues for which no templates are available. # Find the template matching each residue, compiling a list of residues for which no templates are available.
bondedToAtom = self._buildBondedToAtomList(topology)
unmatched_residues = list() # list of unmatched residues unmatched_residues = list() # list of unmatched residues
for chain in topology.chains(): for chain in topology.chains():
for res in chain.residues(): for res in chain.residues():
...@@ -603,7 +625,7 @@ class ForceField(object): ...@@ -603,7 +625,7 @@ class ForceField(object):
Parameters Parameters
---------- ----------
topology : Topology topology : Topology
The Topology for which to create a System The Topology whose residues are to be checked against the forcefield residue templates.
Returns Returns
------- -------
...@@ -615,14 +637,8 @@ class ForceField(object): ...@@ -615,14 +637,8 @@ class ForceField(object):
""" """
# Get a non-unique list of unmatched residues. # Get a non-unique list of unmatched residues.
unmatched_residues = self.getUnmatchedResidues(topology) unmatched_residues = self.getUnmatchedResidues(topology)
# Record which atoms are bonded to each other atom
bondedToAtom = []
for atom in topology.atoms():
bondedToAtom.append(set())
for bond in topology.bonds():
bondedToAtom[bond.atom1.index].add(bond.atom2.index)
bondedToAtom[bond.atom2.index].add(bond.atom1.index)
# Generate a unique list of unmatched residues by comparing fingerprints. # Generate a unique list of unmatched residues by comparing fingerprints.
bondedToAtom = self._buildBondedToAtomList(topology)
unique_unmatched_residues = list() unique_unmatched_residues = list()
signatures = set() signatures = set()
for residue in unmatched_residues: for residue in unmatched_residues:
......
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