Is composed of#
Checking whether a molecular system is composed exclusively 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.
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.is_composed_of()
.
Let’s illustrate how this function works with an example:
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
Tip
All functions defined in the molsysmt.basic module are also accessible from the top-level namespace. Thus, molsysmt.is_composed_of()
is equivalent to molsysmt.basic.is_composed_of()
.
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
See also
User guide > Introduction > Molecular System > Elements:
Describe the hierarchical structure of elements in a molecular system.
User guide > Tools > Basic > Convert:
Convert a molecular system into another form.
User guide > Tools > Basic > Info:
Display summary information about the contents of a molecular system.
User guide > Tools > Basic > Contains:
Check whether specific elements are present in a molecular system.