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. Its output is a new molecular system with the elements and structures selected by the user. A composite input, such as a topology file paired with a coordinate trajectory, is materialized as a native molsysmt.MolSys before extraction so both domains remain aligned. For an H5MSM file input, provide a different output_filename to write a subset, or request to_form='molsysmt.MolSys' to keep the subset in memory.

Added in version 1.0.0.

Basic usage#

Let’s show how this function works using a PDB structure (181L):

import molsysmt as msm
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 ion 2 2 2 2 2
2 2-HYDROXYETHYL DISULFIDE small molecule 8 1 1 1 1
3 BENZENE small molecule 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"]')
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