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.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.basic.contains().
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')
Note
Demo Systems Catalog
This tutorial uses demonstration datasets provided by MolSysMT. To explore the full catalog of bundled systems, forms, and file paths, visit the Demo Systems guide.
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
Tip
All methods defined in the molsysmt.basic module can also be invoked from the main level of the library. Hence, molsysmt.contains() is the same function as molsysmt.basic.contains().
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
See also
Related Tools & References
Get: Retrieve attribute values from a molecular system with
molsysmt.basic.get().Convert: Convert a molecular system into another form or forms with
molsysmt.basic.convert().Info: Print a summary of the contents, topology, and structural data of a molecular system with
molsysmt.basic.info().Select: Select elements from a molecular system with
molsysmt.basic.select().