Skip to content

Commit

Permalink
Extended the .atom(s), .residue(s), .bond(s) and all other
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chryswoods committed Oct 27, 2023
1 parent 3f23cdc commit 599b2eb
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 69 deletions.
13 changes: 13 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
(default True) to rotate velocities as well as coordinates when usign
a cursor to rotate molecule views. This fixes issue #103.

* 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
a ``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.

* Please add an item to this changelog when you create your PR

`2023.4.1 <https://github.com/openbiosim/sire/compare/2023.4.0...2023.4.1>`__ - October 2023
Expand Down
Loading

0 comments on commit 599b2eb

Please sign in to comment.