Is composed of#

Checking whether a molecular system is composed of specific elements.

The function molsysmt.basic.is_composed_of() checks whether a molecular system is made up exclusively of certain types or number of elements.

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

We know in advance that the system includes multiple molecule types: proteins, ions, waters, and small molecules. Therefore, although it contains proteins, it is not composed solely of proteins:

msm.is_composed_of(molsys, proteins=True)
False

Let’s see now if the molecular system is indeed composed of proteins, waters, small molecules and ions:

msm.is_composed_of(molsys, proteins=True, waters=True, small_molecules=True, ions=True)
True

You can also specify the exact number of each element type using keyword arguments. For example:

msm.is_composed_of(molsys, proteins=1, waters=True, small_molecules=2, ions=True)
True
msm.is_composed_of(molsys, proteins=1, small_molecules=1)
False

Other element types, such as atoms, groups, components or molecules, can also be checked using their respective attribute names:

msm.is_composed_of(molsys, n_atoms=1441, n_groups=302)
True
msm.is_composed_of(molsys, n_components=3, n_molecules=3)
False

Finally, you can apply this function to a selection of elements using the selection argument:

msm.is_composed_of(molsys, selection='molecule_type in ["ion", "water", "small molecule", "protein"]')
True
msm.is_composed_of(molsys, selection='molecule_type not in ["ion", "water", "small molecule"]', proteins=1)
True