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.
How this function works#
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.basic.contains().
Let’s illustrate 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
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
Convert:
Convert a molecular system into another form.
Info:
Display a summary of the contents, topology, and structural data of a molecular system.
Get:
Retrieve attribute values from a molecular system.
Select:
Select elements from a molecular system.
Is composed of:
Check if a molecular system is composed of specific types of elements.