Skip to content

Commit 8fa4031

Browse files
committed
Fix hybridisation change check.
1 parent 59d2b14 commit 8fa4031

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/ghostly/_ghostly.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,14 +2227,18 @@ def _check_rotamer_anchors(
22272227

22282228
lam = int(is_lambda1)
22292229

2230-
# Link the molecule to the desired end state and convert to RDKit.
2231-
if is_lambda1:
2232-
end_state_mol = _morph.link_to_perturbed(mol)
2233-
else:
2234-
end_state_mol = _morph.link_to_reference(mol)
2235-
2230+
# Check hybridisation and ring membership at the state where the ghost is
2231+
# physically present. For bridges0, the ghost is physically present at
2232+
# lambda=1 (it is ghost/virtual at lambda=0). For bridges1, the ghost is
2233+
# physically present at lambda=0. Using the opposite state avoids false
2234+
# positives from transmuting bridge atoms: e.g. a nitrile carbon (SP,
2235+
# rigid) that becomes Cl (SP3) at the other end state would otherwise be
2236+
# incorrectly flagged as a rotatable bond.
22362237
try:
2237-
rdmol = to_rdkit(end_state_mol)
2238+
if is_lambda1:
2239+
rdmol = to_rdkit(_morph.link_to_reference(mol))
2240+
else:
2241+
rdmol = to_rdkit(_morph.link_to_perturbed(mol))
22382242
except Exception as e:
22392243
_logger.warning(f"Failed to convert molecule to RDKit for rotamer check: {e}")
22402244
return mol

0 commit comments

Comments
 (0)