Set#
Setting attribute values (topological or structural) to a molecular system.
Some attributes of a molecular system can be changed without altering its identity — for example, modifying the box dimensions, coordinates, or forcefield information. In other cases, attribute corrections may be required, such as fixing a wrong residue name or atom type. MolSysMT provides the molsysmt.basic.set() function to assist with these tasks.
The list of attributes defined in MolSysMT for a molecular system can be checked in the section User guide > Introduction > Molecular system > Attributes.
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.set().
To illustrate how this function works, lets load a molecular system:
import molsysmt as msm
molsys = msm.convert('181L')
msm.info(molsys)
| form | n_atoms | n_groups | n_components | n_chains | n_molecules | n_entities | n_waters | n_ions | n_small_molecules | n_proteins | n_structures |
|---|---|---|---|---|---|---|---|---|---|---|---|
| molsysmt.MolSys | 1441 | 302 | 141 | 6 | 141 | 5 | 136 | 2 | 2 | 1 | 1 |
Suppose that the name of the group at index 30 is incorrect in our system:
msm.info(molsys, element='atom', selection='group_index==30')
| index | id | name | type | group index | group id | group name | group type | component index | chain index | molecule index | molecule type | entity index | entity name |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 248 | 249 | N | N | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 249 | 250 | CA | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 250 | 251 | C | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 251 | 252 | O | O | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 252 | 253 | CB | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 253 | 254 | CG | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 254 | 255 | ND1 | N | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 255 | 256 | CD2 | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 256 | 257 | CE1 | C | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 257 | 258 | NE2 | N | 30 | 31 | HIS | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
Let’s now assume that the histidine residue should be labeled as “HSD” instead of “HIS”. This can be easily updated using the function molsysmt.basic.set():
msm.set(molsys, selection='group_index==30', group_name='HSD')
Tip
All methods defined in the molsysmt.basic module can be invoked also from the main level of the library. Hence, molsysmt.set() is the same method as molsysmt.basic.set().
Let’s check that the group name changed in deed:
msm.info(molsys, element='atom', selection='group_index==30')
| index | id | name | type | group index | group id | group name | group type | component index | chain index | molecule index | molecule type | entity index | entity name |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 248 | 249 | N | N | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 249 | 250 | CA | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 250 | 251 | C | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 251 | 252 | O | O | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 252 | 253 | CB | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 253 | 254 | CG | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 254 | 255 | ND1 | N | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 255 | 256 | CD2 | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 256 | 257 | CE1 | C | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
| 257 | 258 | NE2 | N | 30 | 31 | HSD | amino acid | 0 | 0 | 0 | protein | 0 | T4 LYSOZYME |
Let’s explore another example, this time modifying a structural attribute. We will look at the coordinates of the “CA” atom in the “HSD” group:
msm.get(molsys, element='atom', selection='group_name=="HSD" and atom_name=="CA"', coordinates=True)
| Magnitude | [[[3.7278 1.6327 1.7646999999999997]]] |
|---|---|
| Units | nanometer |
There is only a single structure in the system, let’s change the coordinates of this former atom to a new value:
msm.set(molsys, selection='group_name=="HSD" and atom_name=="CA"', structure_indices=0, coordinates='[0,0,0] nm')
Finally, let’s verify that the coordinates of the “CA” atom in the “HSD” group were updated correctly:
msm.get(molsys, element='atom', selection='group_name=="HSD" and atom_name=="CA"', coordinates=True)
| Magnitude | [[[0.0 0.0 0.0]]] |
|---|---|
| Units | nanometer |
See also
User guide > Introduction > Molecular System > Attributes:
Overview of attributes defined for molecular systems in MolSysMT.
User guide > Tools > Basic > Convert:
Convert molecular systems between different formats.
User guide > Tools > Basic > Info:
Display structural and topological summaries.
User guide > Tools > Basic > Select:
Select elements from a molecular system using various syntaxes.
User guide > Tools > Basic > Get:
Retrieve attribute values from selected elements.