molsysmt.basic.has_attribute#
- molsysmt.basic.has_attribute(molecular_system, attribute, include_none=False, structure_indices='all', chemical_state='reference', skip_digestion=False)[source]#
Checking whether a molecular system has a specific attribute.
This function returns True if the given attribute is available for the input molecular system, and False otherwise. Availability depends on the form-specific backend and the global attribute registry.
- Parameters:
molecular_system (molecular system) – Molecular system to analyze, in any of the supported forms.
attribute (str) – Name of the attribute to check.
include_none (bool, default False) – Whether to consider attributes currently holding None as available. If True, an attribute that exists but is None will return True.
structure_indices (int, tuple, list, numpy.ndarray or 'all', default 'all') – Structures used when
chemical_state='structure'resolves state-dependent availability.chemical_state ({'reference', 'structure'} or int, default 'reference') – Chemical state used to resolve state-dependent attribute availability.
'structure'uses the unique state associated with structure_indices.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.
- Returns:
True if the attribute is available in the molecular system, False otherwise.
- Return type:
bool
- Raises:
NotSupportedFormError – If the molecular system has a form that is not supported.
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.
For native multi-state systems,
chemical_stateresolves availability without changing the topology’s reference state.Explicit integer state selection currently requires a native Topology or MolSys.
See also
molsysmt.basic.get_attributes()Retrieve the list of available attributes in a molecular system.
molsysmt.basic.get()Retrieve values of specific attributes from a molecular system.
Examples
>>> import molsysmt as msm >>> from molsysmt import systems >>> molsys = msm.convert(systems['T4 lysozyme L99A']['181l.h5msm']) >>> msm.has_attribute(molsys, 'box') True >>> msm.has_attribute(molsys, 'forcefield') False
Tutorial with more examples
See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Has attribute.
Added in version 1.0.0.