Skip to content

Commit

Permalink
sssr fixed for disconnected graphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stsouko committed Feb 21, 2019
1 parent fd88c50 commit 5982051
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CGRtools/algorithms/sssr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def sssr(self):
if len(adj) < 3:
return []

atoms = {x for x, y in adj.items() if len(y)} # ignore isolated atoms
atoms = {x for x, y in adj.items() if y} # ignore isolated atoms
terminals = {x for x, y in adj.items() if len(y) == 1}
if terminals:
bubble = terminals
Expand All @@ -48,7 +48,7 @@ def sssr(self):
if not atoms:
return []

n_sssr = self.bonds_count - len(self) + 1
n_sssr = sum(1 for x in atoms for _ in adj[x].keys() & atoms) // 2 - len(atoms) + 1
terminated = {}
tail = atoms.pop()
next_stack = {x: [[tail, x]] for x in adj[tail].keys() & atoms}
Expand Down
33 changes: 33 additions & 0 deletions test/cycle.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,37 @@ $$$$
3 8 1 0 0 0 0
8 7 1 0 0 0 0
M END
$$$$



17 10 0 0 0 0 999 V2000
3.9243 5.3086 0.1050 O 0 0 0 0 0 0 0 0 0 1 0 0
2.9247 5.3358 0.1050 C 0 0 0 0 0 0 0 0 0 2 0 0
7.2401 5.3329 0.2124 C 0 5 0 0 0 0 0 0 0 3 0 0
6.6322 6.1308 0.2124 C 0 0 0 0 0 0 0 0 0 4 0 0
6.6659 4.5137 0.2124 C 0 0 0 0 0 0 0 0 0 5 0 0
5.6893 5.7996 0.2124 C 0 0 0 0 0 0 0 0 0 6 0 0
5.7089 4.8017 0.2124 C 0 0 0 0 0 0 0 0 0 7 0 0
3.9549 2.6641 0.0000 C 0 0 0 0 0 0 0 0 0 8 0 0
3.2511 2.0000 0.0000 C 0 0 0 0 0 0 0 0 0 9 0 0
3.6044 3.5136 0.3542 C 0 0 0 0 0 0 0 0 0 10 0 0
4.6894 2.3635 0.5335 C 0 0 0 0 0 0 0 0 0 11 0 0
2.1600 2.0000 0.0000 C 0 6 0 0 0 0 0 0 0 12 0 0
0.0000 0.0000 0.0000 H 0 0 0 0 0 0 0 0 0 13 0 0
1.0000 0.0000 0.0000 Ni 0 0 0 0 0 0 0 0 0 14 0 0
2.0000 0.0000 0.0000 Ru 0 0 0 0 0 0 0 0 0 15 0 0
3.0000 0.0000 0.0000 Ru 0 0 0 0 0 0 0 0 0 16 0 0
4.0000 0.0000 0.0000 Ru 0 0 0 0 0 0 0 0 0 17 0 0
1 2 3 0 0 0 0
3 4 1 0 0 0 0
3 5 1 0 0 0 0
4 6 2 0 0 0 0
5 7 2 0 0 0 0
6 7 1 0 0 0 0
8 9 1 0 0 0 0
8 10 1 0 0 0 0
8 11 1 0 0 0 0
9 12 2 0 0 0 0
M END
$$$$

0 comments on commit 5982051

Please sign in to comment.