Get attributes#

Getting the list of attributes of a molecular system’s form.

Moleculars systems have attributes such as number of atoms, group ids, box shape or water model. The set of attributes of a system and its elements defines the system. It is what makes a molecular system different from others. And given that a system can take different forms, the number of attributes is limited by each form. For instance, a PDB file (form:”file:pdb”) can store the atom names of a protein and the spatial coordinates of at least one structure, but the sequence of the one-letter code of its aminoacids (form:”string:aminoacids1”) defines also a molecular system (the same system) but with an only attribute -the group names- (without atom names and spatial coordinates). As such, the set of attributes of a specific form of a molecular system form contains all the information about the system this form can store or provide.

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 systems’ form, the function molsysmt.form.get_attributes() returns a dictionary or a list where the user can find whether or not a specific attribute is present.

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.form.get_attributes().

import molsysmt as msm
dict_attributes = msm.form.get_attributes('openmm.Topology')

Let’s inspect the resultant dictionary printing out only the keys with True value:

print([key for key,value in dict_attributes.items() if value])

As it was mentioned before, not all forms have the same attributes. Let’s illustrate this having five different forms:

dict_attributes_A = msm.form.get_attributes('file:pdb')
dict_attributes_B = msm.form.get_attributes('molsysmt.MolSys')
dict_attributes_C = msm.form.get_attributes('openmm.Topology')
dict_attributes_D = msm.form.get_attributes('XYZ')
dict_attributes_E = msm.form.get_attributes('string:amino_acids_3')

We can check now what forms have group names:

attribute = 'group_name'

print('In A:', dict_attributes_A[attribute])
print('In B:', dict_attributes_B[attribute])
print('In C:', dict_attributes_C[attribute])
print('In D:', dict_attributes_D[attribute])
print('In E:', dict_attributes_E[attribute])

Or what forms have entity names, box, or coordinates:

attribute = 'entity_name'

print('In A:', dict_attributes_A[attribute])
print('In B:', dict_attributes_B[attribute])
print('In C:', dict_attributes_C[attribute])
print('In D:', dict_attributes_D[attribute])
print('In E:', dict_attributes_E[attribute])
attribute = 'box'

print('In A:', dict_attributes_A[attribute])
print('In B:', dict_attributes_B[attribute])
print('In C:', dict_attributes_C[attribute])
print('In D:', dict_attributes_D[attribute])
print('In E:', dict_attributes_E[attribute])