Remove overlapping molecules#
Removing solvent or ligand molecules that spatially overlap with other components in a molecular system.
The function molsysmt.build.remove_overlapping_molecules() detects and deletes entire molecules (such as solvent waters or counterions) whose atoms sterically clash with a target solute selection.
Added in version 1.0.0.
API documentation
Follow this link for a detailed description of the input arguments, raised errors, and returned objects of this function: molsysmt.build.remove_overlapping_molecules().
Basic usage#
Let’s show how this function works by merging a water box and a peptide, then removing the clashing water molecules:
import molsysmt as msm
import numpy as np
box = np.array([[[3.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]]]) * msm.pyunitwizard.unit('nanometer')
water_box = msm.build.make_water_box(box)
peptide = msm.build.build_peptide('ACEALAALANME')
peptide = msm.structure.center(peptide, center_coordinates=np.array([[[1.5, 1.5, 1.5]]]) * msm.pyunitwizard.unit('nanometer'))
molsys = msm.merge([water_box, peptide])
n_waters_before = msm.get(molsys, n_waters=True)
print(f'Initial water molecules: {n_waters_before}')
Initial water molecules: 899
Now we run molsysmt.build.remove_overlapping_molecules() to strip water molecules that clash with the peptide:
molsys_clean = msm.build.remove_overlapping_molecules(molsys, selection='molecule_type=="water"')
n_waters_after = msm.get(molsys_clean, n_waters=True)
print(f'Remaining water molecules: {n_waters_after}')
print(f'Removed {n_waters_before - n_waters_after} overlapping water molecules.')
Remaining water molecules: 863
Removed 36 overlapping water molecules.
Quantitative clash verification#
We verify with molsysmt.structure.get_contacts() that zero steric clashes remain below a 0.2 nm threshold between the solvent and peptide:
clashes = msm.structure.get_contacts(molsys_clean, selection='molecule_type=="water"', selection_2='molecule_type=="peptide"', threshold='0.2 nm')
print(f'Any steric clashes remaining: {np.any(clashes)}')
Any steric clashes remaining: False
See also
Related Tools & References
Make water box: Generate pre-equilibrated water boxes with
molsysmt.build.make_water_box().Build peptide: Build linear peptide structures with
molsysmt.build.build_peptide().Merge: Combine multiple molecular components into a single system with
molsysmt.basic.merge().Get contacts: Calculate boolean contact matrices and detect clashes with
molsysmt.structure.get_contacts().Solvate: Solvate structures and set up periodic boundary conditions with
molsysmt.build.solvate().