if element == "H":
if atom.GetNeighbors():
nei_idx = atom.GetNeighbors()[0].GetIdx()
if nei_idx in mapping_inv:
result[element]["excess"].append(mapping_inv[nei_idx])
else:
result[element]["excess"].append(-1)
else: # lone hydrogen
raise ValueError(f"Lone hydrogen {atom.GetMonomerInfo().GetName()} found from input structure")
If we allow the lone hydrogens to pass, the bad residue with lone hydrogens will be deleted silently (no template match results printed) from the result structure.
But alternatively, lone hydrogens can be detected at an earlier point than template matching.
When input PDB has lone hydrogens (from a strained structure),
atom.GetNeighbors()
becomes an empty tuple and an error will occur from here: https://github.com/forlilab/Meeko/blob/c938ebdc347bda69f0247dbd3c7566e8e27d1dea/meeko/polymer.py#L2519-L2524To raise an error:
If we allow the lone hydrogens to pass, the bad residue with lone hydrogens will be deleted silently (no template match results printed) from the result structure.
But alternatively, lone hydrogens can be detected at an earlier point than template matching.