Contains#

Checking whether a molecular system contains specific elements or attributes.

The function molsysmt.basic.contains() allows to check whether or not a molecular system contains certain elements or attributes without needing to call molsysmt.basic.get() directly.

Added in version 1.0.0.

Basic usage#

Let’s show how this function works using the T4 lysozyme dataset (181l.bcif.gz):

import molsysmt as msm
molsys = msm.convert(msm.systems['T4 lysozyme L99A']['181l.bcif.gz'], to_form='molsysmt.MolSys')
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

Let’s check if the system contains water molecules:

msm.contains(molsys, waters=True)
True

We can also check whether the system includes periodic boundary conditions (box):

msm.contains(molsys, box=True)
True

Now let’s verify if the system contains ions, small molecules, and proteins:

msm.contains(molsys, ions=True, small_molecules=True, proteins=True)
True

You can also check for the absence of specific elements or attributes by setting their value to False:

msm.contains(molsys, proteins=True, lipids=False)
True

Or check whether the system contains a specific minimum count of molecules by passing an integer threshold:

msm.contains(molsys, small_molecules=2, ions=2)
True
msm.contains(molsys, small_molecules=2, proteins=2)
False

The input argument selection can be used to test whether specific atom selections exist in the system:

msm.contains(molsys, selection='hydrogens')
False
msm.contains(molsys, selection='molecule_type!="water" and atom_name==["CA", "CB"]')
True

Finally, you can combine a selection with additional attribute conditions:

msm.contains(molsys, selection='molecule_type!="water"', small_molecules=2)
True
msm.contains(molsys, selection='molecule_type!="water"', waters=True)
False