molsysmt.basic.is_composed_of#

molsysmt.basic.is_composed_of(molecular_system, selection='all', syntax='MolSysMT', skip_digestion=False, **kwargs)[source]#

Checking whether a molecular system is composed exclusively of specific elements.

This function returns True if the selected portion of the molecular system is entirely composed of the requested element types and counts provided via keyword conditions in **kwargs; otherwise it returns False.

Parameters:
  • molecular_system (molecular system) – Molecular system to analyze, provided in any of the supported forms.

  • selection (int, tuple, list, numpy.ndarray or str, default 'all') – Subset of the molecular system to check. It can be a 0-based index collection or a selection string following Selection syntaxes. If ‘all’, the entire molecular system is considered.

  • 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 – Composition conditions as name=value pairs. Accepted names include type counters (n_ions, n_waters, n_small_molecules, n_peptides, n_proteins, n_dnas, n_rnas, n_lipids, n_polysaccharides, n_saccharides, …) and element counters (n_atoms, n_groups, n_components, n_molecules, n_chains, n_entities, …). Values are interpreted as: - True → the count must be > 0 (presence required) - False → the count must be == 0 (absence required) - int → the count must be exactly that integer

Returns:

True if all provided conditions are satisfied by the selection; False otherwise.

Return type:

bool

Raises:
  • NotSupportedFormError – If the molecular system has an unsupported form.

  • ArgumentError – If any argument is 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 specific elements from a molecular system.

molsysmt.basic.contains()

Check whether certain elements or attributes are present in a molecular system.

Examples

>>> import molsysmt as msm
>>> from molsysmt import systems
>>> molsys = systems['T4 lysozyme L99A']['181l.h5msm']
>>> msm.basic.is_composed_of(molsys, waters=True, ions=True)
False
>>> msm.basic.is_composed_of(molsys, waters=True, ions=True, small_molecules=2, proteins=1)
True
>>> msm.basic.is_composed_of(molsys, n_chains=6)
True

Tutorial with more examples

See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Is composed of.

Added in version 1.0.0.