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: - molecule (Molecule) –
- selector (collections.abc.Callable) –
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. Returns: Return type: bool
-
vermouth.selectors.
proto_multi_templates
(node, templates, ignore_keys=())[source]¶ Return True is the node matched one of the templates.
Parameters: - node (dict) – The atom/node to consider.
- templates (collections.abc.Iterable[dict]) – A list of node templates to compare to the node.
- ignore_keys (collections.abc.Collection) – List of keys to ignore from the templates.
Returns: Return type: See also
-
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: Returns: Return type:
-
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) – Returns: Return type: bool