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. And given that a system can take different forms, the attributes are also limited by each form.
Hint
Visit the section User guide > Introduction > Molecular System in case you are not familiar with the concepts of “form” or “attribute” in MolSysMT.
The list of attributes defined in MolSysMT for a molecular system can be checked in the section User guide > Introduction > Molecular system > Attributes. And given a molecular system, the function molsysmt.basic.get_attributes()
returns a dictionary where the user can find whether or not a specific attribute with a value different from None
is present.
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.get_attributes()
.
import molsysmt as msm
/home/diego/Myopt/miniconda3/envs/MolSysMT@uibcdf_3.12/lib/python3.12/site-packages/nglview/__init__.py:12: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
molecular_system = msm.convert('181L', to_form='openmm.Topology')
dict_attributes = msm.get_attributes(molecular_system)
Tip
All methods defined in the molsysmt.basic module can be invoked also from the main level of the library. Hence, molsysmt.get_attributes()
is the same method 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)
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
User guide > Introduction > Molecular System > Forms:
Description of the different forms used for molecular systems.
User guide > Introduction > Molecular System > Attributes:
List and definition of the attributes available in MolSysMT for molecular systems.
User guide > Tools > Basic > Convert:
Convert a molecular system into another form or format.
User guide > Tools > Basic > Has attribute:
Check if a molecular system has a specific attribute.
User guide > Tools > Form > Get attributes:
List attributes available for a specific molecular system.
User guide > Tools > Form > Has attribute:
Check if a specific form supports an attribute.