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.

Added in version 1.0.0.

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')

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]]]
Unitsnanometer

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]]]
Unitsnanometer