molsysmt.basic.where_is_attribute#

molsysmt.basic.where_is_attribute(molecular_system, attribute, include_none=False, skip_digestion=False)[source]#

Locating the item where a specific attribute is found.

A molecular system can be composed of multiple items in different forms. This function returns the item and its form where the given attribute is available. If include_none is False, items that have the attribute but with value None will be ignored.

Parameters:
  • molecular_system (molecular system) – Molecular system in any supported MolSysMT format.

  • attribute (str) – Name of the molecular-system attribute to locate or inspect.

  • include_none (bool, default=False) – Whether to include attributes whose value is None.

  • skip_digestion (bool, default=False) – Whether to skip MolSysMT’s internal argument digestion mechanism.

Returns:

  • item – The item in which the attribute was found.

  • str – The form of the item where the attribute was found.

Notes

  • Supported molecular-system forms are described in Items and Forms.

  • If multiple items contain the same attribute, the last matching one is returned.

  • A structural attribute is only looked for in items spanning the structure axis of the molecular system, which is the largest number of structures any of its items carries. An item holding a single reference conformation therefore does not supply a structural series for a trajectory held by another item, and the rule above applies only among the items that do span the axis. This makes the result independent of the order the items were listed in. When the attribute exists solely off the axis, both outputs are None and a StructuralAttributeOffAxisWarning is emitted.

  • If no item contains the attribute both outputs will be None.

See also

molsysmt.basic.has_attribute()

Checking whether a molecular system contains a given attribute.

molsysmt.basic.get_attributes()

Retrieving the list of attributes present in a molecular system.

Examples

>>> import molsysmt as msm
>>> from molsysmt import systems
>>> structure = systems['pentalanine']['pentalanine.inpcrd']
>>> topology = systems['pentalanine']['pentalanine.prmtop']
>>> molecular_system = [topology, structure]
>>> item, form = msm.basic.where_is_attribute(molecular_system, 'box')
>>> form
'file:inpcrd'
>>> item, form = msm.basic.where_is_attribute(molecular_system, 'atom_id')
>>> form
'file:prmtop'

Tutorial with more examples

See the following tutorial for a practical demonstration of how to use this function, along with additional examples: Where is attribute

Added in version 1.0.0.