Skip to content

Commit de7b39f

Browse files
author
Oliver Scott
committed
fragmentation bug fix
1 parent c649c85 commit de7b39f

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

scaffoldgraph/core/fragment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def fragment(self, scaffold):
145145
# Collect all removable atoms in the molecule
146146
remove_atoms = set()
147147
for index, atom in zip(ring.aix, ring.atoms):
148-
if rings.info.NumAtomRings(index) == 1:
148+
if rings.info.NumAtomRings(index) == 1 or any([not b.IsInRing() for b in atom.GetBonds()]):
149149
if atom.GetDegree() > 2: # Evoke linker collection
150150
collect_linker_atoms(edit.GetAtomWithIdx(index), remove_atoms)
151151
else: # Add ring atom to removable set
@@ -236,7 +236,7 @@ def fragment(self, scaffold):
236236
edit = RWMol(scaffold.mol)
237237
remove_atoms = set()
238238
for index, atom in zip(ring.aix, ring.atoms):
239-
if info.NumAtomRings(index) == 1:
239+
if info.NumAtomRings(index) == 1 or any([not b.IsInRing() for b in atom.GetBonds()]):
240240
if atom.GetDegree() > 2: # Evoke linker collection
241241
collect_linker_atoms(edit.GetAtomWithIdx(index), remove_atoms)
242242
else:

scaffoldgraph/core/scaffold.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,10 @@ def get_attachment_points(self, include_exocyclic=False):
353353
ri = self.owner.rings.info
354354
for atom in self.atoms:
355355
index = atom.GetIdx()
356-
if ri.NumAtomRings(index) == 1:
356+
if (
357+
ri.NumAtomRings(index) == 1 or
358+
any([not b.IsInRing() for b in atom.GetBonds()])
359+
):
357360
if atom.GetDegree() > 2:
358361
if (
359362
include_exocyclic is False
@@ -615,10 +618,9 @@ def get_attachment_points(self, include_exocyclic=False):
615618
616619
"""
617620
attachments = set()
618-
ri = self.owner.rings.info
619621
for atom in self.atoms:
620622
index = atom.GetIdx()
621-
if ri.NumAtomRings(index) == 1:
623+
if any([not b.IsInRing() for b in atom.GetBonds()]):
622624
if atom.GetDegree() > 2:
623625
if (
624626
include_exocyclic is False

0 commit comments

Comments
 (0)