Remove overlapping molecules#
import molsysmt as msm
from molsysmt import pyunitwizard as puw
import numpy as np
box = np.zeros((3,3))
box[0,0] = 3.0
box[1,1] = 3.0
box[2,2] = 3.0
box = msm.pyunitwizard.quantity(box, 'nm')
water_box = msm.build.make_water_box(box)
peptide = msm.build.build_peptide('ACEALAALANME')
peptide = msm.structure.center(peptide, center_coordinates=0.5*box.diagonal())
molsys = msm.merge([water_box, peptide])
msm.info(molsys)
form | n_atoms | n_groups | n_components | n_chains | n_molecules | n_entities | n_waters | n_peptides | n_structures |
---|---|---|---|---|---|---|---|---|---|
molsysmt.MolSys | 2729 | 903 | 900 | 2 | 900 | 2 | 899 | 1 | 1 |
new_molsys = msm.build.remove_overlapping_molecules(molsys, selection='molecule_type=="water"')
msm.get(new_molsys, n_waters=True)
863
new_molsys = msm.build.remove_overlapping_molecules(molsys, selection='atom_type!="H" and molecule_type=="water"',
selection_2='atom_type!="H" and molecule_type=="peptide"',
threshold='3 angstroms')
msm.get(new_molsys, n_waters=True)
881
contact_map = msm.structure.get_contacts(new_molsys, selection='atom_type!="H" and molecule_type=="water"',
selection_2='atom_type!="H" and molecule_type=="peptide"',
threshold='3 angstroms', pbc=True)
np.any(contact_map)
False