while len(to_check) > 0:
aid = to_check.pop()
if aid in visited_atoms:
continue
visited_atoms.add(aid)
atom = mol.GetAtomWithIdx(aid)
for atom2 in atom.GetNeighbors():
After Change
residues = set()
for aid in atom_ids:
info = mol.GetAtomWithIdx(aid).GetPDBResidueInfo()
residue = (info.GetResidueNumber(), info.GetResidueName().strip(),
info.GetChainId())
residues.add(residue)
if len(residues) > 1: