vermouth.selectors module

Provides helper function for selecting part of a system, e.g. all proteins, or protein backbones.

vermouth.selectors.filter_minimal(molecule, selector)[source]

Yield the atom keys that match the selector.

The selector must be a function that accepts an atom as a argument. The atom is passed as a node attribute dictionary. The selector must return True for atoms to keep in the selection.

The function can be used to build a subgraph that only contains the selection:

selection = molecule.subgraph(
     filter_minimal(molecule, selector_function)
)
Parameters:
Yields:

collections.abc.Hashable – Keys of the atoms that match the selection.

vermouth.selectors.is_protein(molecule)[source]

Return True if all the residues in the molecule are protein residues.

The function tests if the residue name of all the atoms in the input molecule are in PROTEIN_RESIDUES.

Parameters:

molecule (Molecule) – The molecule to test.

Return type:

bool

vermouth.selectors.proto_multi_templates(node, templates, ignore_keys=())[source]

Return True is the node matched one of the templates.

Parameters:
Return type:

bool

vermouth.selectors.proto_select_attribute_in(node, attribute, values)[source]

Return True if the given attribute of the node is in a list of values.

To be used as a selector, the function must be wrapped in a way that it can be called without the need to explicitly specify the ‘attribute’ and ‘values’ arguments. This can be done using functools.partial():

>>> # select an atom if its name is in a given list
>>> to_keep = ['BB', 'SC1']
>>> select_name_in = functools.partial(
...     proto_select_attribute_in,
...     attribute='atomname',
...     values=to_keep
... )
>>> select_name_in(node)
Parameters:
  • node (dict) – The atom/node to consider.

  • attribute (str) – The key to look at in the node.

  • values (list) – The values the node attribute can take for the node to be selected.

Return type:

bool

vermouth.selectors.select_all(_)[source]

Returns True for all particles.

vermouth.selectors.select_backbone(node)[source]

Returns True if node is in a protein backbone.

vermouth.selectors.selector_has_position(atom)[source]

Return True if the atom have a position.

An atom is considered as not having a position if: * the “position” key is not defined; * the value of “position” is None; * the coordinates are not finite numbers.

Parameters:

atom (dict)

Return type:

bool