"wrappers/vscode:/vscode.git/clone" did not exist on "1004e6e5b02f122d2a1ea366312421167c2231b3"
Commit a19806d2 authored by peastman's avatar peastman
Browse files

Merge pull request #140 from peastman/master

In rare situations, _matchResidue() would take a very long time to return
parents d2dde018 edb3759b
...@@ -516,6 +516,27 @@ def _matchResidue(res, template, bondedToAtom): ...@@ -516,6 +516,27 @@ def _matchResidue(res, template, bondedToAtom):
bonds = [renumberAtoms[x] for x in bondedToAtom[atom.index] if x in renumberAtoms] bonds = [renumberAtoms[x] for x in bondedToAtom[atom.index] if x in renumberAtoms]
bondedTo.append(bonds) bondedTo.append(bonds)
externalBonds.append(len([x for x in bondedToAtom[atom.index] if x not in renumberAtoms])) externalBonds.append(len([x for x in bondedToAtom[atom.index] if x not in renumberAtoms]))
# For each unique combination of element and number of bonds, make sure the residue and
# template have the same number of atoms.
residueTypeCount = {}
for i, atom in enumerate(atoms):
key = (atom.element, len(bondedTo[i]), externalBonds[i])
if key not in residueTypeCount:
residueTypeCount[key] = 1
residueTypeCount[key] += 1
templateTypeCount = {}
for i, atom in enumerate(template.atoms):
key = (atom.element, len(atom.bondedTo), atom.externalBonds)
if key not in templateTypeCount:
templateTypeCount[key] = 1
templateTypeCount[key] += 1
if residueTypeCount != templateTypeCount:
return None
# Recursively match atoms.
if _findAtomMatches(atoms, template, bondedTo, externalBonds, matches, hasMatch, 0): if _findAtomMatches(atoms, template, bondedTo, externalBonds, matches, hasMatch, 0):
return matches return matches
return None return None
......
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