Extract#
Extracting a subset of atoms and structures from a molecular system.
The function molsysmt.basic.extract()
allows you to extract a subset of a molecular system based on atom selections and structure indices. It’s output is a new molecular system with the elements and structures selected by the user.
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.extract()
.
Let’s see molsysmt.basic.extract()
in action with a simple example:
import molsysmt as msm
/home/diego/Myopt/miniconda3/envs/MolSysMT@uibcdf_3.12/lib/python3.12/site-packages/nglview/__init__.py:12: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
molsys = msm.convert('181L')
msm.info(molsys, element='entity')
index | name | type | n atoms | n groups | n components | n chains | n molecules |
---|---|---|---|---|---|---|---|
0 | T4 LYSOZYME | protein | 1289 | 162 | 1 | 1 | 1 |
1 | CHLORIDE ION | unknown | 2 | 2 | 2 | 2 | 2 |
2 | 2-HYDROXYETHYL DISULFIDE | unknown | 8 | 1 | 1 | 1 | 1 |
3 | BENZENE | unknown | 6 | 1 | 1 | 1 | 1 |
4 | water | water | 136 | 136 | 136 | 1 | 136 |
We will extract only the protein and benzene entities from the system by using a selection based on entity_name
.
molsubsys = msm.extract(molsys, selection='entity_name in ["T4 LYSOZYME", "BENZENE"]')
Tip
All methods defined in the molsysmt.basic module can be invoked also from the main level of the library. Hence, molsysmt.extract()
is the same method as molsysmt.basic.extract()
.
msm.info(molsubsys, element='entity')
index | name | type | n atoms | n groups | n components | n chains | n molecules |
---|---|---|---|---|---|---|---|
0 | T4 LYSOZYME | protein | 1289 | 162 | 1 | 1 | 1 |
1 | BENZENE | small molecule | 6 | 1 | 1 | 1 | 1 |
See also
User guide > Tools > Basic > Convert:
Convert a molecular system into another form.
User guide > Tools > Basic > Info:
Display summary information about a molecular system.