Get attributes#
Retrieving the set of available attributes in a molecular system.
Molecular systems have attributes such as the number of atoms, the group ids, the box shape or the water model. The set of attribute values of a system and its elements defines a molecular system, making it different from others. Given that a system can take different forms, the attributes are also limited by each form. Given a molecular system, the function molsysmt.basic.get_attributes() returns a dictionary indicating whether each attribute is present with a non-None value.
Hint
Visit the section Items and Forms or Attributes if you are not familiar with the concepts of “form” or “attribute” 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.get_attributes().
Basic usage#
Let’s show how this function works using an OpenMM Topology converted from PDB 181L:
import molsysmt as msm
molecular_system = msm.convert('181L', to_form='openmm.Topology')
dict_attributes = msm.get_attributes(molecular_system, output_type='dictionary')
Tip
All methods defined in the molsysmt.basic module can also be invoked from the main level of the library. Hence, molsysmt.get_attributes() is the same function as molsysmt.basic.get_attributes().
Let’s inspect the resultant dictionary:
dict_attributes['box_volume']
True
dict_attributes['forcefield']
False
As mentioned earlier, not all molecular systems have all attributes with non-None values.. If this is the case, the function molsysmt.basic.get_attributes() returns False for these attributes -although they can be contained in the corresponding molecular system’s form-:
msm.set(molecular_system, box=None)
dict_attributes = msm.get_attributes(molecular_system, output_type='dictionary')
dict_attributes['box_volume']
False
Note
Have a look to the function molsysmt.form.has_attribute() if the presence of a specific attribute needs to be checked in a molecular system. However, if instead of the attributes of a molecular system, the attributes of a molecular system’s form need to be checked make use of the functions molsysmt.form.get_attributes() and molsysmt.form.has_attribute().
See also
Related Tools & References
Items and Forms: Description of the different forms used for molecular systems.
Attributes: List and definition of the attributes available in MolSysMT for molecular systems.
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().Has attribute: Check whether a molecular system or form has specific attributes with
molsysmt.basic.has_attribute().