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])
['atom_index', 'atom_name', 'atom_id', 'atom_type', 'group_index', 'group_name', 'group_id', 'group_type', 'component_index', 'component_name', 'component_id', 'component_type', 'chain_index', 'chain_name', 'chain_id', 'chain_type', 'molecule_index', 'molecule_name', 'molecule_id', 'molecule_type', 'entity_index', 'entity_type', 'bond_index', 'bonded_atoms', 'bonded_atom_pairs', 'inner_bonded_atoms', 'inner_bonded_atom_pairs', 'inner_bond_index', 'n_atoms', 'n_groups', 'n_components', 'n_chains', 'n_molecules', 'n_entities', 'n_bonds', 'n_inner_bonds', 'n_amino_acids', 'n_ions', 'n_waters', 'n_small_molecules', 'n_peptides', 'n_proteins', 'n_dnas', 'n_rnas', 'n_lipids', 'n_oligosaccharides', 'n_saccharides', 'box', 'box_shape', 'box_angles', 'box_lengths', 'box_volume']
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:mmtf')
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])
In A: True
In B: True
In C: True
In D: False
In E: True
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])
In A: True
In B: True
In C: False
In D: False
In E: False
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])
In A: True
In B: True
In C: True
In D: False
In E: False