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. In order to check whether or not a molecular has a specific attribute value, MolSysMT provides a specific function in the basic
module: molsysmt.basic.has_attribute()
.
Added in version 1.0.0.
How this function works#
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()
.
Let’s illustrate the use of molsysmt.basic.has_attribute()
with the following examples.
import molsysmt as msm
molsys = msm.systems['pentalanine']['pentalanine.inpcrd']
msm.has_attribute(molsys, attribute='box')
True
Tip
All methods defined in the molsysmt.basic module can be invoked also from the main level of the library. Hence, molsysmt.has_attribute()
is the same method 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
None
for 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
User guide > Introduction > Molecular System > Attributes:
List and describe the standard attributes available for molecular systems in MolSysMT.
User guide > Tools > Basic > Get attributes:
Check which attributes are present in a given molecular system.
User guide > Tools > Form > Get attributes:
List the attributes available for a specific form.
User guide > Tools > Form > Has attribute:
Check whether a form supports a given attribute.