molsysmt.basic.contains#
- molsysmt.basic.contains(molecular_system, selection='all', syntax='MolSysMT', skip_digestion=False, **kwargs)[source]#
Checking whether a molecular system contains specific elements or satisfies conditions.
This function returns a boolean indicating whether the molecular system, or a selected subset of it, satisfies a set of conditions expressed via keyword arguments. Each keyword corresponds to an attribute to check, and its value specifies the condition to apply.
- Parameters:
molecular_system (molecular system) – Molecular system to analyze, in any of the supported forms.
selection (str, tuple, list or numpy.ndarray, default 'all') – Subset of atoms the conditions are applied to. Either a 0-based index collection or a selection string parsed according to Selection syntaxes. The default ‘all’ applies the conditions to the entire system.
syntax (str, default 'MolSysMT') – Selection syntax used when selection is a string. See Selection syntaxes.
skip_digestion (bool, default False) – Whether to skip MolSysMT’s internal argument digestion mechanism. MolSysMT includes a built-in digestion system that validates and normalizes function arguments. This process checks types, shapes, and values, and automatically adjusts them when possible to meet expected formats. Setting skip_digestion=True disables this process, which may improve performance in workflows where inputs are already validated. Use with caution: only set this to True if you are certain all input arguments are correct and consistent.
**kwargs –
Attribute conditions expressed as
attribute=value
pairs, where the value can be: - True: the attribute must be present and non-zero/non-empty on the selected subset. - False: the attribute must be absent or zero/empty on the selected subset. - int: the attribute (interpreted as a count/size) must be greater than or equal tothe given integer (threshold).
- Returns:
True if all specified conditions are satisfied by the selected subset of the system; otherwise, False.
- Return type:
bool
- Raises:
NotSupportedFormError – If the molecular system is not in a supported form.
ArgumentError – If input arguments are invalid or inconsistent.
Notes
Supported molecular-system forms are summarized in Forms.
Selection strings must follow one of the syntaxes described in Selection syntaxes.
See also
molsysmt.basic.select()
Select elements from a molecular system.
molsysmt.basic.is_composed_of()
Check if a molecular system is composed of specific types of elements.
Examples
>>> import molsysmt as msm >>> molsys = msm.systems['T4 lysozyme L99A']['181l.h5msm'] >>> msm.contains(molsys, waters=True, ions=True) True >>> msm.contains(molsys, selection='atom_name=="CL"') True >>> msm.contains(molsys, selection='molecule_type!="water"', waters=True) False
User guide
See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Contains.
Added in version 1.0.0.