1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
|
- # -*- mode: org -*-
- Archived entries from file /home/salotz/tree/lab/projects/wepy.lysozyme_test/project.org
- * Running simulations
- :PROPERTIES:
- :ARCHIVE_TIME: 2019-11-14 Thu 21:19
- :ARCHIVE_FILE: ~/tree/lab/projects/wepy.lysozyme_test/project.org
- :ARCHIVE_CATEGORY: project
- :END:
- ** Standalone Runs
- To validate that our system is okay we do a couple of standalone runs
- on the system.
- *** Script
- Here is a script for running a basic kind of simulation:
- #+begin_src python :tangle scripts/run.py
- import simtk.openmm as omm
- import simtk.openmm.app as omma
- import simtk.unit as unit
- import mdtraj as mdj
- from openmmtools import testsystems
- # from seh_prep.modules import StateDataFrameOMMReporter
- STEP_TIME = 0.002 * unit.picoseconds
- LANGEVIN_DEFAULTS = (
- 300.0*unit.kelvin,
- 1/unit.picosecond,
- STEP_TIME
- )
- PLATFORM = 'CPU'
- FRAME_INTERVAL_TIME = 10 * unit.picosecond
- FRAME_INTERVAL = int(round(FRAME_INTERVAL_TIME / STEP_TIME))
- def gen_sim(platform):
- integrator = omm.LangevinIntegrator(*LANGEVIN_DEFAULTS)
- test_sys = testsystems.LysozymeImplicit()
- # write a PDB file for reference
- top = mdj.Topology.from_openmm(test_sys.topology)
- traj = mdj.Trajectory(test_sys.positions.value_in_unit(unit.nanometer), topology=top)
- traj.save_pdb('ref.pdb')
- if platform == 'CUDA':
- platform_kwargs = {'Precision' : 'single'}
- elif platform == 'OpenCL':
- platform_kwargs = {"Precision" : 'single'}
- elif platform == 'CPU':
- platform_kwargs = {}
- elif platform == 'Reference':
- platform_kwargs = {}
- else:
- raise ValueError
- platform = omm.Platform.getPlatformByName(platform)
- simulation = omma.Simulation(test_sys.topology, test_sys.system, integrator,
- platform=platform,
- platformProperties=platform_kwargs)
- simulation.context.setPositions(test_sys.positions)
- # add some reporters
- simulation.reporters.append(omma.DCDReporter('traj.dcd',
- reportInterval=FRAME_INTERVAL,
- enforcePeriodicBox=False))
- # simulation.reporters.append(StateDataFrameOMMReporter(report_interval=10))
- simulation.reporters.append(omma.StateDataReporter('state.csv',
- FRAME_INTERVAL,
- step=True,
- time=True,
- potentialEnergy=True,
- kineticEnergy=True,
- totalEnergy=True,
- temperature=True,
- volume=True,
- ))
- return simulation
- if __name__ == "__main__":
- import sys
- import time
- # time in sampling to run
- sim_time = float(sys.argv[1]) #* unit.second
- platform = sys.argv[2]
- print("Running simulation for {}".format(sim_time))
- tranche_time = 10 * unit.picosecond
- tranche_steps = int(round(tranche_time / STEP_TIME))
- print(f"running tranches of {tranche_steps} steps")
- simulation = gen_sim(platform)
- print("Starting the simulation")
- curr_time = 0.
- step_counter = 0
- start_time = time.time()
- while curr_time < sim_time:
- print("starting from step {}".format(step_counter))
- print(type(tranche_steps))
- simulation.step(tranche_steps)
- curr_time = time.time() - start_time
- step_counter += tranche_steps
- print("Ran {}".format(step_counter))
- print("Time currently is: {}".format(curr_time))
- # add up the sampling time
- sampling_time = step_counter * STEP_TIME
- print(f"Ran a total of {step_counter} steps")
- print(f"Ran a total of {sampling_time}")
- #+end_src
- *** run settings
- #+BEGIN_SRC toml :tangle hpcc/standalone/run_settings.toml
- # test run value
- walltime = "24:00:00"
- memory = "20gb"
- num_cpus = 2
- # test run value
- num_gpus = 1
- constraint = "[intel18|intel16]"
- #+END_SRC
- *** context settings
- #+BEGIN_SRC toml :tangle hpcc/standalone/context_settings.toml
- [context]
- # its okay to leave out the exec dir, but you can specify this and the
- #run will get executed here and then be moved back
- # exec_dir = "$SCRATCH/exec"
- # epilog is something that can be run after the run, if it is empty
- # here that is okay, this is really only important for moving data
- # back after being executed somewhere else
- epilog = ""
- # this section is for the setup of the run in the script
- [context.setup]
- # this is the parent dir for the jobs, there should be a directory
- # here called 'jobs' and each job will will get it's own unique
- # directory
- goal_dir_path = "$SCRATCH/tree/lab/projects/wepy.lysozyme_test/hpcc/standalone"
- # will load these modules from lmod i.e. 'module load <modname>'
- lmod_modules = ["CUDA/10.0.130"]
- # everything in here is translated directly into environment
- # variables, e.g. "export ANACONDA_DIR=path/to/anaconda"
- [context.setup.env_vars]
- ANACONDA_DIR = "/mnt/home/lotzsamu/anaconda3"
- #+END_SRC
- *** Tasks
- **** 1
- #+begin_src bash :shebang "#!/bin/bash --login" :tangle hpcc/standalone/tasks/initial.sh
- source $HOME/.bashrc
- # use the ANACONDA_DIR which is set in the environment variables in
- # the setup to setup this shell for anaconda
- . ${ANACONDA_DIR}/etc/profile.d/conda.sh
- # activate the proper virtualenv
- conda activate lysozyme_test
- # this will run for under 24 hours
- script="$SCRATCH/tree/lab/projects/wepy.lysozyme_test/scripts/run.py"
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python $script 84000 CUDA
- #+end_src
- *** Retrieving results
- #+begin_src bash
- rsync -ravvhhiz \
- lotzsamu@rsync.hpcc.msu.edu:/mnt/gs18/scratch/users/lotzsamu/tree/lab/projects/wepy.lysozyme_test/hpcc/standalone/jobs/ \
- $HOME/tree/lab/projects/wepy.lysozyme_test/hpcc/standalone/jobs
- #+end_src
- ** Wepy Runs
- To validate that our system is okay we do a couple of standalone runs
- on the system.
- *** By Time
- Here is a script for running a basic kind of simulation:
- #+begin_src python :tangle scripts/wepy_run_by_time.py
- if __name__ == "__main__":
- import sys
- import logging
- from multiprocessing_logging import install_mp_handler
- from wepy_tools.sim_makers.openmm.lysozyme import LysozymeImplicitOpenMMSimMaker
- logging.getLogger().setLevel(logging.DEBUG)
- install_mp_handler()
- if sys.argv[1] == "-h" or sys.argv[1] == "--help":
- print("arguments: n_cycles, n_steps, n_walkers, n_workers, platform, resampler")
- else:
- walltime = int(sys.argv[1])
- #n_cycles = int(sys.argv[1])
- n_steps = int(sys.argv[2])
- n_walkers = int(sys.argv[3])
- n_workers = int(sys.argv[4])
- platform = sys.argv[5]
- resampler = sys.argv[6]
- print("Number of steps: {}".format(n_steps))
- print("Time to run: {}".format(walltime))
- # print("Number of cycles: {}".format(n_cycles))
- sim_maker = LysozymeImplicitOpenMMSimMaker()
- apparatus = sim_maker.make_apparatus(
- integrator='LangevinIntegrator',
- resampler=resampler,
- bc='UnbindingBC',
- platform=platform,
- )
- config = sim_maker.make_configuration(apparatus,
- work_mapper='TaskMapper',
- platform=platform)
- sim_manager = sim_maker.make_sim_manager(n_walkers, apparatus, config)
- sim_manager.run_simulation_by_time(walltime, n_steps, num_workers=n_workers)
- #+end_src
- *** By Num Cycles
- Here is a script for running a basic kind of simulation:
- #+begin_src python :tangle scripts/wepy_run_by_cycles.py
- if __name__ == "__main__":
- import sys
- import logging
- from multiprocessing_logging import install_mp_handler
- from wepy_tools.sim_makers.openmm.lysozyme import LysozymeImplicitOpenMMSimMaker
- logging.getLogger().setLevel(logging.DEBUG)
- install_mp_handler()
- if sys.argv[1] == "-h" or sys.argv[1] == "--help":
- print("arguments: n_cycles, n_steps, n_walkers, n_workers, platform, resampler")
- else:
- n_cycles = int(sys.argv[1])
- n_steps = int(sys.argv[2])
- n_walkers = int(sys.argv[3])
- n_workers = int(sys.argv[4])
- platform = sys.argv[5]
- resampler = sys.argv[6]
- print("Number of steps: {}".format(n_steps))
- print("Number of cycles: {}".format(n_cycles))
- sim_maker = LysozymeImplicitOpenMMSimMaker()
- apparatus = sim_maker.make_apparatus(
- integrator='LangevinIntegrator',
- resampler=resampler,
- bc='UnbindingBC',
- platform=platform,
- )
- config = sim_maker.make_configuration(apparatus,
- work_mapper='TaskMapper',
- platform=platform)
- sim_manager = sim_maker.make_sim_manager(n_walkers, apparatus, config)
- sim_manager.run_simulation_by_time(n_cycles, n_steps, num_workers=n_workers)
- #+end_src
- *** run settings
- #+BEGIN_SRC toml :tangle hpcc/wepy/run_settings.toml
- # test run value
- walltime = "168:00:00"
- memory = "20gb"
- num_cpus = 4
- num_gpus = 8
- constraint = "[intel18|intel16]"
- #+END_SRC
- *** context settings
- #+BEGIN_SRC toml :tangle hpcc/wepy/context_settings.toml
- [context]
- # its okay to leave out the exec dir, but you can specify this and the
- #run will get executed here and then be moved back
- # exec_dir = "$SCRATCH/exec"
- # epilog is something that can be run after the run, if it is empty
- # here that is okay, this is really only important for moving data
- # back after being executed somewhere else
- epilog = ""
- # this section is for the setup of the run in the script
- [context.setup]
- # this is the parent dir for the jobs, there should be a directory
- # here called 'jobs' and each job will will get it's own unique
- # directory
- goal_dir_path = "$SCRATCH/tree/lab/projects/wepy.lysozyme_test/hpcc/wepy"
- # will load these modules from lmod i.e. 'module load <modname>'
- lmod_modules = ["CUDA/10.0.130"]
- # everything in here is translated directly into environment
- # variables, e.g. "export ANACONDA_DIR=path/to/anaconda"
- [context.setup.env_vars]
- ANACONDA_DIR = "/mnt/home/lotzsamu/anaconda3"
- #+END_SRC
- *** Tasks
- **** NoResampler test
- #+begin_src bash :shebang "#!/bin/bash" :tangle hpcc/wepy/tasks/noresampler_test.sh
- # use the ANACONDA_DIR which is set in the environment variables in
- # the setup to setup this shell for anaconda
- . ${ANACONDA_DIR}/etc/profile.d/conda.sh
- # activate the proper virtualenv
- conda activate lysozyme_test
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python -m simtk.testInstallation
- WALLTIME=590400
- N_STEPS=10000 # 20 picoseconds
- N_WALKERS=48
- N_WORKERS=8
- PLATFORM="CUDA"
- RESAMPLER="NoResampler"
- script="$SCRATCH/tree/lab/projects/wepy.lysozyme_test/scripts/wepy_run_by_time.py"
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python $script \
- $WALLTIME \
- $N_STEPS \
- $N_WALKERS \
- $N_WORKERS \
- $PLATFORM \
- $RESAMPLER
- #+end_src
- **** WExplore test
- #+begin_src bash :shebang "#!/bin/bash" :tangle hpcc/wepy/tasks/wexplore_test.sh
- # use the ANACONDA_DIR which is set in the environment variables in
- # the setup to setup this shell for anaconda
- . ${ANACONDA_DIR}/etc/profile.d/conda.sh
- # activate the proper virtualenv
- conda activate lysozyme_test
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python -m simtk.testInstallation
- WALLTIME=590400
- N_STEPS=10000 # 20 picoseconds
- N_WALKERS=48
- N_WORKERS=8
- PLATFORM="CUDA"
- RESAMPLER="WExploreResampler"
- script="$SCRATCH/tree/lab/projects/wepy.lysozyme_test/scripts/wepy_run_by_time.py"
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python $script \
- $WALLTIME \
- $N_STEPS \
- $N_WALKERS \
- $N_WORKERS \
- $PLATFORM \
- $RESAMPLER
- #+end_src
- **** REVO test
- #+begin_src bash :shebang "#!/bin/bash" :tangle hpcc/wepy/tasks/revo_test.sh
- # use the ANACONDA_DIR which is set in the environment variables in
- # the setup to setup this shell for anaconda
- . ${ANACONDA_DIR}/etc/profile.d/conda.sh
- # activate the proper virtualenv
- conda activate lysozyme_test
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python -m simtk.testInstallation
- WALLTIME=590400
- N_STEPS=10000 # 20 picoseconds
- N_WALKERS=48
- N_WORKERS=8
- PLATFORM="CUDA"
- RESAMPLER="REVOResampler"
- script="$SCRATCH/tree/lab/projects/wepy.lysozyme_test/scripts/wepy_run_by_time.py"
- ${ANACONDA_DIR}/envs/lysozyme_test/bin/python $script \
- $WALLTIME \
- $N_STEPS \
- $N_WALKERS \
- $N_WORKERS \
- $PLATFORM \
- $RESAMPLER
- #+end_src
- *** Retrieving results
- #+begin_src bash
- rsync -ravvhhiz \
- lotzsamu@rsync.hpcc.msu.edu:/mnt/gs18/scratch/users/lotzsamu/tree/lab/projects/wepy.lysozyme_test/hpcc/wepy/jobs/ \
- $HOME/tree/lab/projects/wepy.lysozyme_test/hpcc/wepy/jobs
- #+end_src
- Archived entries from file /home/salotz/tree/lab/projects/wepy.lysozyme_test/project.org
- * Analysis
- We only consider the wepy runs here. The standalone was just a test.
- ** Tasks
- *** Initialization
- Domain specific stuff related to working with the project:
- **** Header
- #+BEGIN_SRC python :tangle lib/wepy_lysozyme/_tasks.py
- """Generated file from the analysis.org file. Do not edit directly."""
- #+END_SRC
- **** Imports
- #+BEGIN_SRC python :tangle lib/seh_pathway_hopping/_tasks.py
- # standard library
- import os
- import os.path as osp
- import pickle
- # de facto standard library
- import numpy as np
- import pandas as pd
- import matplotlib.pyplot as plt
- import prefect
- # extra non-domain specific
- import joblib
- import sqlalchemy as sqla
- # 3rd party domain specific
- import mdtraj as mdj
- import simtk.unit as unit
- # auxiliary supporting repos
- import geomm
- import wepy
- # truly ad hoc
- #+END_SRC
- **** Paths
- #+BEGIN_SRC python :tangle lib/seh_pathway_hopping/_tasks.py
- ## Paths
- # for localizing paths to very commonly used resources and resrouces
- # which may change schema. The directory structure for the rest is the
- # schema, so just use osp.join(project_path(), 'subpath/to/resource')
- # for the rest so a lot of work is reduced in specifying all of them
- def projects_path():
- user_home = osp.expanduser('~')
- studio = osp.join(user_home, 'tree/lab/studio')
- projects = osp.join(studio, 'projects/index')
- return projects
- def project_path():
- return osp.join(projects_path(), 'seh.pathway_hopping')
- def data_path():
- return osp.join(project_path(), 'data')
- def media_path():
- return osp.join(project_path(), 'media')
- def sqlite_path():
- return osp.join(project_path(), 'db/db.sqlite')
- def joblib_cache_path():
- return osp.join(project_path(), 'cache/joblib')
- #+END_SRC
- **** Setup
- Set up caching of the tasks.
- #+BEGIN_SRC python :tangle lib/seh_pathway_hopping/_tasks.py
- ## Setup
- # create the sqlite database
- # set up the joblib cache
- jlmem = joblib.Memory(joblib_cache_path())
- # set this when you want to do some recursion stuff with contigtrees
- def set_recursion_limit():
- recursion_limit = 5000
- import sys; sys.setrecursionlimit(recursion_limit)
- print("Setting recursion limit to {}".format(recursion_limit))
- # set the recursion depth since it is always needing to be increased
- set_recursion_limit()
- #+END_SRC
- *** Visualizing Trajectories
- For each run we want to visualize trajectories of the simulations no
- matter if we get exit points are not.
- So we get traces for every end point.
-
|