RMeli / spyrmsdkit

MDAnalysis Kit (MDAKit) for SPyRMSD
GNU General Public License v2.0
2 stars 0 forks source link

Use only bonds within atom group to build adjacency matrix #1

Closed RMeli closed 7 months ago

RMeli commented 8 months ago

When a selection cuts across bonds, the resulting AtomGroup's bond attribute also contains bonds to atoms outside of the atom group. This results in anIndexError when building the adjacency matrix.

This PR uses get_connections("bonds", outside=False) to get only bonds within atoms of the selection, while the previous behavior corresponded to get_connections("bonds", outside=True).


Thanks @ldx022 for testing out spyrmsdkit and reporting the issue in https://github.com/RMeli/spyrmsd/discussions/99.

Thanks @alibay for suggesting get_connections(), the original fix was the following:

    b = ag.bonds.to_indices()

    # Remove dangling bonds
    # An AtomGroup can contain bonds to atoms that are not part of the AtomGroup
    mask = np.isin(b[:, 0], ag.atoms.indices) & np.isin(
        b[:, 1], ag.atoms.indices
    )
    b = b[mask, :]
RMeli commented 8 months ago

CI is not triggered, will need to be investigated.

codecov[bot] commented 7 months ago

Welcome to Codecov :tada:

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered :open_umbrella:

RMeli commented 7 months ago

Python 3.12 does not currently work in CI. See #2.