Set#
Setting attribute values to a molecular system.
Some attributes of a molecular system can be changed without altering its identity — for example, modifying box dimensions, coordinates, stable isotope mass numbers, or force field parameters. In other cases, attribute corrections may be required, such as fixing a group name or atom type. MolSysMT provides the molsysmt.basic.set() function to assist with these tasks.
Hint
Visit the section Attributes for a detailed overview of attributes 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.set().
Basic usage#
Let’s show how this function works using a PDB structure (181L):
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 also be invoked from the main level of the library. Hence, molsysmt.set() is the same function 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
Related Tools & References
Attributes: Overview of topological and structural attributes defined for molecular systems in MolSysMT.
Convert: Convert molecular systems between different forms with
molsysmt.basic.convert().Info: Display structural and topological summaries of a molecular system with
molsysmt.basic.info().Set: Set attribute values to a molecular system with
molsysmt.basic.set().Get: Retrieve attribute values from selected elements with
molsysmt.basic.get().Select: Select elements from a molecular system using selection syntax with
molsysmt.basic.select().