def setup(self): distance_pairs = list(itertools.product(range(4), range(4, 6))) dist = { pair: paths.MDTrajFunctionCV(name="dist" + str(pair), f=md.compute_distances, topology=topology, atom_pairs=[list(pair)]) for pair in distance_pairs } min_dist = paths.MDTrajFunctionCV( name="min_dist", topology=topology, f=lambda traj, pairs: \ md.compute_distances(traj, atom_pairs=pairs).min(axis=1), pairs=list(dist.keys()), cv_scalarize_numpy_singletons=False ) self.bound_state = paths.CVDefinedVolume(dist[(0, 4)], 0.0, 0.06) \ and paths.CVDefinedVolume(dist[(1, 5)], 0.0, 0.06) self.unbound_state = paths.CVDefinedVolume(min_dist, 0.2, float("inf")) self.excluded_volume = ( paths.CVDefinedVolume(dist[(0, 4)], 0.0, 0.075) and paths.CVDefinedVolume(dist[(0, 5)], 0.0, 0.075) and paths.CVDefinedVolume(dist[(1, 4)], 0.0, 0.075) and paths.CVDefinedVolume(dist[(1, 5)], 0.0, 0.075)) self.ensemble = MultipleBindingEnsemble( initial_state=self.bound_state, known_states=[self.bound_state, self.unbound_state], stable_contact_state=stable_contact_state, excluded_volume=self.excluded_volume)
def _wc_hg_TPS_network(self, topology): # separated for readability, not re-usability d_WC = paths.MDTrajFunctionCV("d_WC", md.compute_distances, topology, atom_pairs=[[275, 494]]) d_HG = paths.MDTrajFunctionCV("d_HG", md.compute_distances, topology, atom_pairs=[[275, 488]]) d_bp = paths.MDTrajFunctionCV("d_bp", md.compute_distances, topology, atom_pairs=[[274, 491]]) state_WC = (paths.CVDefinedVolume(d_WC, 0.0, 0.35) & paths.CVDefinedVolume(d_bp, 0.0, 0.35)).named("WC") state_HG = (paths.CVDefinedVolume(d_HG, 0.0, 0.35) & paths.CVDefinedVolume(d_bp, 0.0, 0.35)).named("HG") network = paths.TPSNetwork(state_WC, state_HG) return network
def test_torsion_vs_mdtraj(self): plmd = PLUMEDInterface(self.topology) tor_md = paths.MDTrajFunctionCV("tor_md", md.compute_dihedrals, self.topology, indices=[[6, 8, 14, 16]]) tor_pl = PLUMEDCV("tor_pl", plmd, "TORSION ATOMS=7,9,15,17") np.testing.assert_almost_equal(tor_md(self.trajectory), tor_pl(self.trajectory), decimal=3)
def test_angle_vs_mdtraj(self): plmd = PLUMEDInterface(self.topology) ang_md = paths.MDTrajFunctionCV("ang_md", md.compute_angles, self.topology, angle_indices=[[4, 6, 8]]) ang_pl = PLUMEDCV("ang_pl", plmd, "ANGLE ATOMS=5,7,9") np.testing.assert_almost_equal(ang_md(self.trajectory), ang_pl(self.trajectory), decimal=3)
def test_distance_vs_mdtraj(self): plmd = PLUMEDInterface(self.topology) dist_md = paths.MDTrajFunctionCV("dist_md", md.compute_distances, self.topology, atom_pairs=[[6, 8]]) dist_pl = PLUMEDCV("dist_pl", plmd, "DISTANCE ATOMS=7,9") np.testing.assert_almost_equal(dist_md(self.trajectory), dist_pl(self.trajectory), decimal=3)
def test_molinfo(self): plmd = PLUMEDInterface(self.topology, molinfo=data_filename("plumed_wrapper/" + "AD_initial_frame.pdb")) tor_md = paths.MDTrajFunctionCV("tor_md", md.compute_dihedrals, self.topology, indices=[[6, 8, 14, 16]]) tor_pl = PLUMEDCV("tor_pl", plmd, "TORSION ATOMS=@psi-2") np.testing.assert_almost_equal(tor_md(self.trajectory), tor_pl(self.trajectory), decimal=3)
def test_rmsd_vs_mdtraj(self): plmd = PLUMEDInterface(self.topology) rmsd_ref_file = data_filename( os.path.join("plumed_wrapper", "AD_plumed_rmsd.pdb")) md_ref = md.load(rmsd_ref_file) rmsd_md = paths.MDTrajFunctionCV("rmsd_md", md.rmsd, self.topology, reference=md_ref, frame=0, atom_indices=range(22)) rmsd_pl = PLUMEDCV("rmsd_pl", plmd, "RMSD REFERENCE=" + rmsd_ref_file + " TYPE=OPTIMAL") np.testing.assert_almost_equal(rmsd_md(self.trajectory), rmsd_pl(self.trajectory), decimal=3)
initial_snapshot = engine.current_snapshot engine_hot.current_snapshot = template engine_hot.minimize() initial_snapshot_hot = engine_hot.current_snapshot storage.tag['cool_template'] = engine.current_snapshot storage.tag['hot_template'] = engine_hot.current_snapshot # Define order parameters # Compute the closest heavy atom distances between receptor and ligand cv_old = paths.MDTrajFunctionCV( name="distance", cv_scalarize_numpy_singletons= False, # needed because compute_contacts() does not return a single numpy array contacts=[[0, 1]], f=md.compute_contacts, topology=template.topology, scheme='closest-heavy', ignore_nonprotein=False, periodic=False).with_diskcache() def distance(snapshot, receptor_atoms, ligand_atoms): import numpy as np receptor_com = snapshot.xyz[receptor_atoms, :].mean(0) ligand_com = snapshot.xyz[ligand_atoms, :].mean(0) return np.sqrt(((receptor_com - ligand_com)**2).sum()) cv = paths.CoordinateFunctionCV(name="distance", f=distance,
# In[5]: hi_T_engine.current_snapshot = template hi_T_engine.minimize() # ## Defining states # # First we define the CVs using the `md.compute_dihedrals` function. Then we define our states using `PeriodicCVDefinedVolume` (since our CVs are periodic.) # In[6]: # define the CVs psi = paths.MDTrajFunctionCV("psi", md.compute_dihedrals, template.topology, indices=[[6,8,14,16]]) phi = paths.MDTrajFunctionCV("phi", md.compute_dihedrals, template.topology, indices=[[4,6,8,14]]) # In[7]: # define the states deg = 180.0/np.pi C_7eq = ( paths.PeriodicCVDefinedVolume(phi, lambda_min=-180/deg, lambda_max=0/deg, period_min=-np.pi, period_max=np.pi) & paths.PeriodicCVDefinedVolume(psi, lambda_min=100/deg, lambda_max=200/deg, period_min=-np.pi, period_max=np.pi) ).named("C_7eq") # similarly, without bothering with the labels: