Skip to content

Fix issue #528 - #530

Merged
lohedges merged 1 commit into
develfrom
fix_528
Nov 11, 2026
Merged

lohedges merged 1 commit into
develfrom
fix_528

Conversation

@lohedges

Copy link
Copy Markdown
Contributor

Closes #528.
Closes #529.

ConnectivityBase::inRing found rings by enumerating paths with findPaths(..., MAX_RING_SIZE), with MAX_RING_SIZE = 12 hard coded, so atoms and bonds in larger rings, e.g. macrocycles, were reported as not being in a ring.

Changes

  • The one- and two-atom overloads (and inRing(BondID)) now use a single depth-first search for the biconnected components of the bond graph (Tarjan's algorithm), so there is no limit on ring size. An atom is in a ring if it belongs to a component of more than two atoms, and two atoms are in the same ring if they share one.
  • The result is cached on the connectivity as a std::shared_ptr, read and written atomically, so it is computed once per molecule. Copies share it, and it is cleared by ConnectivityEditor::connect, disconnect and disconnectAll, and when streamed in.
  • The three-atom, four-atom, AngleID and DihedralID overloads keep using findPaths, with a new optional max_ring_size argument that defaults to 12. It is now the actual largest ring size matched: the overloads look for two paths between the end atoms that share no other atoms, forming a ring of at most max_ring_size atoms that contains all of the passed atoms. Queries whose atoms aren't in a common ring system are rejected from the cache before any path search.
  • Fixed Connectivity.make_compatible_with keeping bonds to removed atoms when the atom matcher doesn't change the order of the atoms, e.g. AtomIdxMatcher. The new ring search visits every atom, so these stale bonds would have caused out-of-bounds reads.
  • Fixed angle, dihedral and improper properties being dropped from the connectivity when the molecule was edited without changing the order of its atoms, e.g. renaming an atom ([BUG] Angle, dihedral and improper connectivity properties lost when a molecule is edited #529).
  • Added tests/mol/test_in_ring.py and tests/mol/test_connectivity.py.

Behaviour changes

  • Rings of more than 12 atoms are now detected by the one- and two-atom overloads. This affects ring-break detection when merging, the ring labels on bonds used by the MCS, and downstream callers of in_ring.
  • For atoms that aren't bonded, the two-atom overload now returns whether they are in the same ring, rather than whether there is more than one path between them. Atoms in separate rings joined by a bond (e.g. biphenyl) or a spiro atom, and a ring atom paired with a substituent, now return False. For bonded atoms the result is unchanged, apart from the size limit.
  • The three-atom overload previously also matched 13-membered rings with the default limit of 12.

Downstream

  • BioSimSpace: no code changes needed. The supplementary in_ring check in _check_ring already assumes these semantics. The ring-break false positive for a pair of atoms in a ring of up to 12 atoms in one end state and 13 to 50 atoms in the other is fixed. The Align tests pass unchanged.
  • Ghostly: the _in_ring workaround can be replaced by Connectivity.in_ring, and the test asserting that Sire misses macrocycles needs flipping.

Checklist

  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): [y]
  • I confirm that I have added a test for any new functionality in this pull request: [y]
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y]
  • I confirm that I have added a changelog entry to the changelog (we will add a link to this PR as part of the review): [y]
  • I confirm that I have permission to release this code under the MIT license (the Python API) or the LGPLv3+ license (everything else), as described in the LICENSE file: [y]

@lohedges lohedges added the bug Something isn't working label Nov 10, 2026
@lohedges lohedges changed the title Fix issue #12 Fix issue #528 Nov 11, 2026
@lohedges
lohedges merged commit 9bcc2ff into devel Nov 11, 2026
4 of 5 checks passed
@lohedges
lohedges deleted the fix_528 branch November 11, 2026 02:26
This was referenced Nov 11, 2026

This branch was previously deployed

1 inactive deployment
sire-build — 127a0007 Deployed Nov 10, 2026 by lohedges via build (3.12, linux) #471
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

1 participant