Skip to content

Commit 872d9c2

Browse files
committed
molecule_draw doesn't increment implicitHydrogens counts when searching for backbone.
Previously it would do a makeHydrogensImplicit() call on a shallow copy of the molecule. This would not delete the hydrogens from that molecule, but WOULD increment the implicitHydrogens counts on the atoms in it, leading to escalating H populations!
1 parent e7931ca commit 872d9c2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

rmgpy/molecule_draw.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,10 @@ def findBackbone(chemGraph, ringSystems):
577577
chemGraph = chemGraph.copy()
578578

579579
# Remove hydrogen atoms from consideration, as they cannot be part of
580-
# the backbone
581-
chemGraph.makeHydrogensImplicit()
580+
# the backbone.
581+
# Do this irreversibly, because we have a copy and we don't want to change
582+
# the implicitHydrogen count of the other atoms.
583+
chemGraph.deleteHydrogens()
582584

583585
# If there are only one or two atoms remaining, these are the backbone
584586
if len(chemGraph.atoms) == 1 or len(chemGraph.atoms) == 2:

0 commit comments

Comments
 (0)