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 in any supported MolSysMT format.
selection (str, list, tuple, or numpy.ndarray, default='all') – Selection string or boolean/integer array specifying elements.
syntax (str, default='MolSysMT') – Selection syntax used to evaluate selection (e.g., ‘MolSysMT’, ‘MDTraj’).
skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.
- 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 Items and 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.