Has attribute#
Checking whether a molecular system has a specific attribute.
Not all molecular system forms include the same attributes, and not all molecular systems have values for every available attribute. For example, an openmm.Topology system supports a periodic box, but a particular molecular system might not define one. To check whether a molecular system has a specific attribute value, use molsysmt.basic.has_attribute().
Hint
Visit the section Attributes for a detailed overview of the attribute model in MolSysMT.
Added in version 1.0.0.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.basic.has_attribute().
Basic usage#
Let’s show how this function works with a demonstration dataset (pentalanine.inpcrd):
import molsysmt as msm
molsys = msm.systems['pentalanine']['pentalanine.inpcrd']
Note
Demo Systems Catalog
This tutorial uses demonstration datasets provided by MolSysMT. To explore the full catalog of bundled systems, forms, and file paths, visit the Demo Systems guide.
msm.has_attribute(molsys, attribute='box')
True
Tip
All methods defined in the molsysmt.basic module can also be invoked from the main level of the library. Hence, molsysmt.has_attribute() is the same function as molsysmt.basic.has_attribute().
The function confirms that two conditions are met:
the “file:inpcrd” molecular system form has the attribute ‘box’
the molecular system has a value different from
Nonefor the attribute ‘box’.
Indeed, we can retrieve the corresponding value:
msm.get(molsys, box=True)
| Magnitude | [[[4.29511093 0.0 0.0] [-1.4317035278131303 4.049469460244502 0.0] [-1.4317035278131303 -2.0247344850669022 3.506943565903758]]] |
|---|---|
| Units | nanometer |
A molecular system may support a given attribute, but the value may still be None. In this case the function molsysmt.basic.has_attribute() returns False. Let’s see this case with the following example:
molsys = msm.convert(msm.systems['pentalanine']['pentalanine.prmtop'], to_form='openmm.Topology')
msm.set(molsys, box=None)
msm.has_attribute(molsys, attribute='box')
False
We can check whether a specific form (regardless of system instance) supports an attribute using molsysmt.form.has_attribute().
msm.form.has_attribute('file:prmtop', attribute='box')
True
Finally, let’s see how molsysmt.basic.has_attribute() behaves when the requested attribute is not supported by the molecular system’s form.
molecular_system = msm.systems['pentalanine']['pentalanine.prmtop']
msm.has_attribute(molsys, attribute='coordinates')
False
See also
Related Tools & References
Attributes: List and describe the standard attributes available for molecular systems in MolSysMT.
Demo Systems Catalog: Access a collection of predefined molecular systems for testing and demonstration purposes.
Has attribute: Check whether a molecular system has a specific attribute with
molsysmt.basic.has_attribute().Get: Retrieve attribute values from a molecular system with
molsysmt.basic.get().Convert: Convert a molecular system into another form or forms with
molsysmt.basic.convert().Set: Set attribute values in a molecular system with
molsysmt.basic.set().Get attributes: Check which attributes are present in a molecular system with
molsysmt.basic.get_attributes().