def test_tzd(self): with open('data/tzd.out') as f, \ open('data/tzd.in') as f2: dash = mdash.DashOutput(f, f2) # check that the mamixum frequency value of each dihedral # state falls within the appropriate range of angles for dih in dash.dihedrals: for state in dih.states: self.assertTrue(any(r.min < state.maximum < r.max for r in state.ranges))
def get_simple_dash(self): dash = mdash.DashOutput([]) dih1 = mdash.Dihedral( '1', [' : 0, 0', ': 1 = [-180, 0), 2 = [0, 180)']) dih2 = mdash.Dihedral( '2', [' : 0, 0', ': 1 = [-180, 0), 2 = [0, 180)']) dash.dihedrals = [dih1, dih2] state1 = mdash.State('1 1 1', [dih1, dih2]) state2 = mdash.State('2 2 1', [dih1, dih2]) state3 = mdash.State('3 1 2', [dih1, dih2]) state4 = mdash.State('4 2 2', [dih1, dih2]) dash.states = [state1, state2, state3, state4] dash._create_null_state() return dash
parser = argparse.ArgumentParser( description='This script demonstrates integration of pymdash with mdtraj' ' to extract the representative frame for each dash state from a raw ' 'trajectory file.') parser.add_argument('dash_out_file', help='Path to the output file from dash') parser.add_argument('trajectory_file', help='Path to the trajectory data file used to provide' ' input for the dash run.') parser.add_argument( '-t', '--topology', help='Path to a suitable structure file that can be ' 'used to derive a topology by mdtraj. See md_traj.load_toplogy for details' ) args = parser.parse_args() if args.topology is not None: topology = md.load_topology(args.topology) else: topology = None with open(args.dash_out_file) as f: dash = mdash.DashOutput(f) print('Writing pdb files for {} dash states'.format(dash.n_states)) for state in dash.states: traj = md.load_frame(args.trajectory_file, state.rep_frame - 1, top=topology) traj.save_pdb('state_{}.pdb'.format(state.index))
def test(self): with open('data/simple_dash.out') as f, \ open('data/simple_dash.in') as f2: dash = mdash.DashOutput(f, f2) self.assertEqual(dash.options['data'], 'angles') self.assertEqual(dash.options['timestep'], '1 ps') self.assertEqual(dash.options['window'], 11) self.assertEqual(dash.options['binsize'], 4) self.assertEqual(dash.options['runlen'], 3) self.assertEqual(dash.options['fmax'], 2.4) self.assertEqual(dash.options['smin'], 48) self.assertEqual(dash.options['boutlen'], 20) self.assertEqual(dash.options['smooth'], 40) self.assertEqual(dash.options['rough'], 20) self.assertEqual(dash.options['repex_fraction'], 0.01) self.assertEqual(dash.n_states, 2) self.assertEqual(dash.n_dihedrals, 12) self.assertEqual(dash.states[0].state_code, '111112111111') self.assertEqual(dash.states[1].state_code, '111111111112') self.assertEqual(dash.states[0].rep_frame, 1) self.assertEqual(dash.states[1].rep_frame, 5) self.assertEqual(dash.states[0].rep_frame_rmsd, 6.83) self.assertEqual(dash.states[1].rep_frame_rmsd, 7.77) self.assertEqual(dash.state_trajectory[0], dash.states[0]) self.assertEqual(dash.state_trajectory[1], dash.states[0]) self.assertEqual(dash.state_trajectory[2], dash.states[0]) self.assertEqual(dash.state_trajectory[3], dash.states[1]) self.assertEqual(dash.state_trajectory[4], dash.states[1]) self.assertEqual(dash.state_trajectory[5], dash.states[0]) self.assertEqual( "".join(["%8.2f" % ang for ang in dash.states[0].mean_angles]), " -159.54 -161.05 -161.17 56.74 -100.26 -86.42 123.95 69.04 169.30 171.69 110.46 -17.15" ) self.assertEqual( "".join(["%8.2f" % ang for ang in dash.states[1].mean_angles]), " -164.29 -153.69 -148.00 65.16 -132.78 -144.98 131.95 62.21 155.42 165.33 132.84 65.27" ) self.assertEqual( "".join(["%8.2f" % ang for ang in dash.states[0].stdev_angles]), " 12.10 6.88 8.04 5.54 12.80 9.08 6.96 9.40 4.90 2.89 4.94 11.07" ) self.assertEqual( "".join(["%8.2f" % ang for ang in dash.states[1].stdev_angles]), " 7.26 0.68 7.34 2.95 0.22 17.79 0.28 6.63 9.12 4.17 4.76 11.51" ) dihedral = dash.dihedrals[0] self.assertEqual(dihedral.get_state(index=1), dihedral.states[0]) self.assertTupleEqual( tuple(dihedral.trajectory), (-168.895278931, -173.250335693, -152.416381836, -171.548736572, -157.039138794, -143.536956787) ) for i, dihedral in enumerate(dash.dihedrals): self.assertEqual( dihedral.state_trajectory, [dihedral.get_state(index=int(state.state_code[i])) for state in dash.state_trajectory])
"""This script demonstrates how to recreate some of the plots from the original dash paper using pymdash. David W. Salt, Brian D. Hudson, et. al., Journal of Medicinal Chemistry 2005 48 (9), 3214-3220 """ import matplotlib.pyplot as plt import mdash with open('data/tzd.out') as f, open('data/tzd.in') as f2: dash = mdash.DashOutput(f, f2) # Figure 6 fig, ax = plt.subplots() ax.plot([state.index for state in dash.state_trajectory], 'x') ax.set_xlabel('Trajectory Frame') ax.set_ylabel('Dash State Index') # Figure 3 N = 5000 dihedral = dash.dihedrals[2] # pick a nice example fig, (ax1, ax2) = plt.subplots(1, 2, gridspec_kw={'width_ratios': [4, 1]}) ax1.plot(dihedral.trajectory[:N], 'o') ax1.plot([state.maximum for state in dihedral.state_trajectory[:N]], 'k') ax1.set_xlabel('Trajectory Frame') ax1.set_ylabel('Dihedral 3 Value') ax2.hist(dihedral.trajectory[:N], bins=50, orientation='horizontal') ax2.invert_xaxis() ax2.set_yticks([]) plt.show()