Commit 17725b68 authored by peastman's avatar peastman
Browse files

Improved logic for matching multi-residue patches

parent e8eb3fba
...@@ -1522,6 +1522,23 @@ def _applyMultiResiduePatch(data, clusters, patch, candidateTemplates, selectedT ...@@ -1522,6 +1522,23 @@ def _applyMultiResiduePatch(data, clusters, patch, candidateTemplates, selectedT
else: else:
residueMatches.append(matches) residueMatches.append(matches)
if residueMatches is not None: if residueMatches is not None:
# Each residue individually matches. Now make sure they're bonded in the correct way.
bondsMatch = True
for a1, a2 in patch.addedBonds:
res1 = a1.residue
res2 = a2.residue
if res1 != res2:
# The patch adds a bond between residues. Make sure that bond exists.
atoms1 = patchedTemplates[res1].atoms
atoms2 = patchedTemplates[res2].atoms
index1 = next(i for i in range(len(atoms1)) if atoms1[residueMatches[res1][i]].name == a1.name)
index2 = next(i for i in range(len(atoms2)) if atoms2[residueMatches[res2][i]].name == a2.name)
atom1 = list(residues[res1].atoms())[index1]
atom2 = list(residues[res2].atoms())[index2]
bondsMatch &= atom2.index in bondedToAtom[atom1.index]
if bondsMatch:
# We successfully matched the template to the residues. Record the parameters. # We successfully matched the template to the residues. Record the parameters.
for i in range(patch.numResidues): for i in range(patch.numResidues):
......
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