Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature bonds #121

Merged
merged 10 commits into from
Oct 30, 2023
Merged

Feature bonds #121

merged 10 commits into from
Oct 30, 2023

Conversation

chryswoods
Copy link
Contributor

Changes proposed in this pull request:

Extended the .atom(s), .residue(s), .bond(s) and all other indexing functions so that you can pass in an existing view or views as the key. This lets you look up views in a container by other views, e.g. mols.bond(mols.atoms()[0], mols.atoms()[1]) would return the bond between the first two atoms in the container mols.

Also added an error_on_missing flag to the atoms, residues, bonds etc functions, so that you get a KeyError exception if there is no match, and error_on_missing is True.

For example, mols.atoms("element C", error_on_missing=True) would raise an exception if there are no carbon atoms in this container.

This is default False to keep existing behaviour, but we would recommend setting this to True and would like to change the default in the future.

  • 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: [n]
  • 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 GPL3 license: [y]

Suggested reviewers:

@lohedges

Any additional context of information?

I've not added documentation as this puts in functionality that makes the code behave more intuitively. I added this because I found that mols.bond(mols.atoms()[0], mols.atoms()[1]) didn't work, even though, intuitively, it should.

This builds on the other PRs. For ease of review, here's the one commit that is new with this PR: 599b2eb

the dynamics code.

Added tests and source documentation.
of the 3 angles. The angles are converted from degrees to radians
when held internally. But they should exactly convert back to the
degrees value via `ang.to(degrees)` as I think division/multiplication
by the same number is reversible.

[ci skip]
[ci skip]
part of the unit test that checks that velocity rotation is working.
indexing functions so that you can pass in an existing view or views as
the key. This lets you look up views in a container by other views, e.g.
`mols.bond(mols.atoms()[0], mols.atoms()[1])` would return the bond
between the first two atoms in the container `mols`.

Also added an `error_on_missing` flag to the `atoms`, `residues`, `bonds` etc
functions, so that you get a `KeyError` exception if there is no match,
and `error_on_missing` is `True`.

For example, `mols.atoms("element C", error_on_missing=True)` would raise
an exception if there are no carbon atoms in this container.

This is default `False` to keep existing behaviour, but we would recommend
setting this to `True` and would like to change the default in the future.
@chryswoods chryswoods temporarily deployed to sire-build October 27, 2023 17:09 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build October 27, 2023 17:09 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build October 27, 2023 17:09 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build October 27, 2023 17:09 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build October 27, 2023 17:09 — with GitHub Actions Inactive
@lohedges lohedges self-requested a review October 30, 2023 14:58
Copy link
Contributor

@lohedges lohedges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this is a really handy piece of functionality. I've tested locally and everything is working as expected. The changes from the other PRs will need manual adjustments behind the scenes in BioSimSpace once this is merged. I'll also need to find some example input so that they can be tested properly.

My only comment is whether the cursor rotation should have any auto-detection for perturbable molecules, or whether this should be left to the user to do, e.g. via the property map. This is what I currently do in my workaround, i.e. rotate 4 times, mapping coordinates to coordinates0, velocity0, coordinates1, and velocity1. Perhaps it could check for the is_perturbable property then search for properties matching map.get("coordinates", "coordinates") + "0" (and lambda 1), etc.

@chryswoods
Copy link
Contributor Author

Thanks - that's a good question. I think the code shouldn't try to be that clever. If the properties are linked, then the rotation would only apply to the coordinates/velocities of the linked state (i.e. the reference or perturbed state). I can imagine situation where the user may want to rotate or translate the end states differently. I can also imagine situations where there's more than one end state, or we have completely different types of merged or complex molecules we want to support. Given this, I think it is better to be explicit rather than implicit, and that it should be left to the user to do two rotations if they want both end states changed.

@chryswoods chryswoods merged commit 72b24cd into devel Oct 30, 2023
5 checks passed
@chryswoods chryswoods deleted the feature_bonds branch October 30, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants