Contains#
Checking whether a molecular system contains specific elements or attributes
The function molsysmt.basic.contains()
can check whether or not a molecular system contains certain elements or attributes without the need to use molsysmt.basic.get()
.
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 following molecular system:
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 |
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:
msm.contains(molsys, box=True)
True
Tip
All methods defined in the molsysmt.basic module can be invoked also from the main level of the library. As such, molsysmt.contains()
is the same method 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:
msm.contains(molsys, proteins=True, lipids=False)
True
Or check whether the system contains a specific number of molecules:
msm.contains(molsys, small_molecules=2, ions=2)
True
msm.contains(molsys, small_molecules=2, proteins=2)
True
The input argument selection
can also be used instead of attributes:
msm.contains(molsys, selection='hydrogens')
False
msm.contains(molsys, selection='molecule_type!="water" and atom_name==["CA", "CB"]')
True
Or combine a selection with additional conditions on elements:
msm.contains(molsys, selection='molecule_type!="water"', small_molecules=2)
True
msm.contains(molsys, selection='molecule_type!="water"', water=True)
False
See also
User guide > Introduction > Molecular System > Elements:
Describe the hierarchical levels of elements in a molecular system, such as atoms, groups, components, molecules, chains, and entities.
User guide > Tools > Basic > Convert:
Convert a molecular system into another form.
User guide > Tools > Basic > Info:
Display summary information of a molecular system.
User guide > Tools > Basic > Get:
Get attributes from a molecular system.