Compare#
Comparing molecular systems across selected attributes.
The function molsysmt.basic.compare()
allows to compare two molecular systems, or specific parts of them, based on selected attributes. The function can return a single boolean or a detailed per-attribute report.
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.compare()
.
Let’s explore how to compare molecular systems using the following three systems:
import molsysmt as msm
molsys_A = msm.convert('pdb_id:181L', to_form='openmm.Modeller')
molsys_B = msm.convert(molsys_A, to_form='molsysmt.MolSys')
molsys_C = msm.extract(molsys_B, selection='molecule_type=="protein"')
The systems \(A\) and \(B\) are equivalent in content—they only differ in form. System \(C\) is a subset of the same molecular system, using the same form as \(B\).
Let’s make some comparisons between these systems to illustrate how molsysmt.basic.compare()
works:
msm.compare(molsys_A, molsys_B)
False
msm.compare(molsys_B, molsys_C)
False
Tip
All methods defined in the molsysmt.basic module can also be invoked from the top level of the library. Therefore, molsysmt.compare()
is equivalent to molsysmt.basic.compare()
.
By default, only the elements are compared. Other attributes as coordinates
, box
or n_groups
can be included explicitly in the comparison:
msm.compare(molsys_A, molsys_B, coordinates=True, box=True, n_groups=True)
True
msm.compare(molsys_B, molsys_C, coordinates=True, box=True, n_groups=True)
False
A detailed report showing the result for each attribute can be obtained by setting the output_type="dictionary"
argument:
msm.compare(molsys_B, molsys_C, coordinates=True, box=True, n_groups=True, output_type='dictionary')
{'n_groups': False, 'box': True, 'coordinates': False}
You can also test for the negation of a condition by setting the attribute value to False
:
msm.compare(molsys_B, molsys_C, coordinates=False, box=True, n_groups=False, output_type='dictionary')
{'n_groups': True, 'box': True, 'coordinates': True}
Remember, you can restrict the comparison to specific elements or structures using the arguments selection
, structure_indices
, selection_2
and structure_indices_2
:
msm.compare(molsys_B, molsys_C, selection='molecule_type=="protein"', selection_2='all',
coordinates=True, box=True, n_groups=True, output_type='dictionary')
{'n_groups': True, 'box': True, 'coordinates': True}
See also
User guide > Tools > Basic > Convert:
Converting a molecular system into a different form.
User guide > Tools > Basic > Extract:
Extracting a portion of a molecular system.