Adaptive sampling#

In this tutorial, we will showcase how to use adaptive sampling simulations on a molecular system. The sample system in this case is the NTL9 protein.

Let’s import HTMD and do some definitions:

from htmd.ui import *
2024-06-11 16:32:33,117 - numexpr.utils - INFO - Note: NumExpr detected 20 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
2024-06-11 16:32:33,117 - numexpr.utils - INFO - NumExpr defaulting to 8 threads.
2024-06-11 16:32:33,286 - rdkit - INFO - Enabling RDKit 2022.09.1 jupyter extensions
Please cite HTMD: Doerr et al.(2016)JCTC,12,1845. https://dx.doi.org/10.1021/acs.jctc.6b00049
HTMD Documentation at: https://software.acellera.com/htmd/

You are on the latest HTMD version (2.3.28+5.g9dbc5091a.dirty).

Get the generators folder structure#

Get the data for this tutorial here. Alternatively, you can download the data using wget:

import os, glob
assert os.system('wget -rcN -np -nH -q --cut-dirs=2 -R index.html* http://pub.htmd.org/tutorials/adaptive-sampling/generators/') == 0
for file in glob.glob('./generators/*/run.sh'):
    os.chmod(file, 0o755)
!tree generators | head -20
generators
β”œβ”€β”€ ntl9_1ns_0
β”‚Β Β  β”œβ”€β”€ input
β”‚Β Β  β”œβ”€β”€ input.coor
β”‚Β Β  β”œβ”€β”€ input.xsc
β”‚Β Β  β”œβ”€β”€ parameters
β”‚Β Β  β”œβ”€β”€ run.sh
β”‚Β Β  β”œβ”€β”€ structure.pdb
β”‚Β Β  └── structure.psf
β”œβ”€β”€ ntl9_1ns_1
β”‚Β Β  β”œβ”€β”€ input
β”‚Β Β  β”œβ”€β”€ input.coor
β”‚Β Β  β”œβ”€β”€ input.xsc
β”‚Β Β  β”œβ”€β”€ parameters
β”‚Β Β  β”œβ”€β”€ run.sh
β”‚Β Β  β”œβ”€β”€ structure.pdb
β”‚Β Β  └── structure.psf
└── ntl9_1ns_2
    β”œβ”€β”€ input
    β”œβ”€β”€ input.coor

Adaptive classes#

HTMD has two types of adaptive sampling:

  • AdaptiveMD (free exploration)

  • AdaptiveGoal (exploration + exploitation)

Create a directory for each type of adaptive and copy the generators into them:

os.makedirs('./adaptivemd', exist_ok=True)
os.makedirs('./adaptivegoal', exist_ok=True)
shutil.copytree('./generators', './adaptivemd/generators')
shutil.copytree('./generators', './adaptivegoal/generators')
'./adaptivegoal/generators'

AdaptiveMD#

Let’s change directory to the adaptivemd one and work there:

os.chdir('./adaptivemd')
  • Setup the queue that will be used for simulations.

  • Tell it to store completed trajectories in the data folder as this is where AdaptiveMD expects them to be by default

queue = LocalGPUQueue()
queue.datadir = './data'
ad = AdaptiveMD()
ad.app = queue
  • Set the nmin, nmax and nepochs

ad.nmin = 1
ad.nmax = 3
ad.nepochs = 3
  • Choose what projection to use for the construction of the Markov model

protsel = 'protein and name CA'
ad.projection = MetricSelfDistance(protsel)
  • Set the updateperiod of the Adaptive to define how often it will poll for completed simulations and redo the analysis

ad.updateperiod = 120 # execute every 2 minutes

Launch the AdaptiveMD run:

ad.run()
2024-06-11 16:32:58,958 - htmd.adaptive.adaptive - INFO - Processing epoch 0
2024-06-11 16:32:58,960 - htmd.adaptive.adaptive - INFO - Epoch 0, generating first batch
2024-06-11 16:32:58,983 - jobqueues.util - INFO - Trying to determine all GPU devices
2024-06-11 16:32:59,035 - jobqueues.localqueue - INFO - Using GPU devices 0
2024-06-11 16:32:59,037 - jobqueues.util - INFO - Trying to determine all GPU devices
2024-06-11 16:32:59,093 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s1_ntl9_1ns_0
2024-06-11 16:32:59,095 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s2_ntl9_1ns_1
2024-06-11 16:32:59,097 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s1_ntl9_1ns_0 on device 0
2024-06-11 16:32:59,101 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s3_ntl9_1ns_2
2024-06-11 16:32:59,105 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:34:59,208 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:34:59,209 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:34:59,209 - htmd.adaptive.adaptive - INFO - 3 simulations in progress
2024-06-11 16:34:59,210 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:35:14,002 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s1_ntl9_1ns_0
2024-06-11 16:35:14,003 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s2_ntl9_1ns_1 on device 0
2024-06-11 16:36:59,319 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:36:59,320 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:36:59,321 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 16:36:59,321 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:37:30,333 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s2_ntl9_1ns_1
2024-06-11 16:37:30,334 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s3_ntl9_1ns_2 on device 0
2024-06-11 16:38:59,420 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:38:59,421 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:38:59,422 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 16:38:59,422 - htmd.adaptive.adaptiverun - INFO - Postprocessing new data
Creating simlist: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:00<00:00, 704.37it/s]
Filtering trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  2.82it/s]
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 316.56it/s]
2024-06-11 16:39:00,784 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 16:39:00,785 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
2024-06-11 16:39:01,850 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
2024-06-11 16:39:01,862 - htmd.adaptive.adaptiverun - WARNING - Using less macrostates than requested due to lack of microstates. macronum = 3
2024-06-11 16:39:02,165 - htmd.model - INFO - 95.0% of the data was used
2024-06-11 16:39:02,166 - htmd.model - INFO - Number of trajectories that visited each macrostate:
2024-06-11 16:39:02,167 - htmd.model - INFO - [2 2]
Writing inputs: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  4.13it/s]
2024-06-11 16:39:02,657 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s1_e1s1p0f4
2024-06-11 16:39:02,657 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s2_e1s2p0f3
2024-06-11 16:39:02,658 - htmd.adaptive.adaptive - INFO - Finished submitting simulations.
2024-06-11 16:39:02,658 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:39:47,336 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e1s3_ntl9_1ns_2
2024-06-11 16:39:47,337 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s1_e1s1p0f4 on device 0
2024-06-11 16:41:02,757 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 16:41:02,759 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:41:02,760 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 16:41:02,761 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:42:04,402 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s1_e1s1p0f4
2024-06-11 16:42:04,403 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s2_e1s2p0f3 on device 0
2024-06-11 16:43:02,860 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 16:43:02,861 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:43:02,862 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 16:43:02,862 - htmd.adaptive.adaptiverun - INFO - Postprocessing new data
Creating simlist: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 5/5 [00:00<00:00, 1180.96it/s]
Filtering trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:00<00:00,  5.07it/s]
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4/4 [00:00<00:00, 293.88it/s]
2024-06-11 16:43:03,931 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 16:43:03,932 - htmd.metricdata - INFO - Dropped 0 trajectories from 4 resulting in 4
2024-06-11 16:43:05,564 - htmd.metricdata - INFO - Dropped 0 trajectories from 4 resulting in 4
2024-06-11 16:43:05,854 - htmd.model - INFO - 100.0% of the data was used
2024-06-11 16:43:05,855 - htmd.model - INFO - Number of trajectories that visited each macrostate:
2024-06-11 16:43:05,856 - htmd.model - INFO - [2 4 4 3 4]
Writing inputs: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  3.53it/s]
2024-06-11 16:43:06,427 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s1_e2s1p0f6
2024-06-11 16:43:06,428 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s2_e1s1p0f1
2024-06-11 16:43:06,429 - htmd.adaptive.adaptive - INFO - Finished submitting simulations.
2024-06-11 16:43:06,429 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:44:21,527 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e2s2_e1s2p0f3
2024-06-11 16:44:21,528 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s1_e2s1p0f6 on device 0
2024-06-11 16:45:06,528 - htmd.adaptive.adaptive - INFO - Processing epoch 3
2024-06-11 16:45:06,529 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:45:06,530 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 16:45:06,531 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:46:38,893 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s1_e2s1p0f6
2024-06-11 16:46:38,894 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s2_e1s1p0f1 on device 0
2024-06-11 16:47:06,628 - htmd.adaptive.adaptive - INFO - Processing epoch 3
2024-06-11 16:47:06,629 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:47:06,629 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 16:47:06,630 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:48:56,028 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivemd/input/e3s2_e1s1p0f1
2024-06-11 16:49:06,740 - htmd.adaptive.adaptive - INFO - Processing epoch 3
2024-06-11 16:49:06,741 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:49:06,741 - htmd.adaptive.adaptive - INFO - 0 simulations in progress
2024-06-11 16:49:06,742 - htmd.adaptive.adaptive - INFO - Reached maximum number of epochs 3

AdaptiveGoal#

Now let’s change to the adaptivegoal directory and work there instead:

os.chdir('../adaptivegoal')
  • Most of the class arguments are identical to AdaptiveMD

adg = AdaptiveGoal()
adg.app = queue
adg.nmin = 1
adg.nmax = 3
adg.nepochs = 2
adg.generatorspath = './generators'
adg.projection = MetricSelfDistance('protein and name CA')
adg.updateperiod = 120  # execute every 2 minutes
adg.goalfunction = None  # set to None just as an example
  • It requires the goalfunction argument which defines a goal

  • We can define a variety of different goal functions

The goal function#

The goal function will: * take as input a Molecule object of a simulation and * produce as output a score for each frame of that simulation. * The higher the score, the more desirable that simulation frame for being respawned.

RMSD goal function#

For this goal function, we will use a crystal structure of NTL9.

You can download the structure from the following link and save it on the adaptivegoal directory:

Alternatively, you can download the structure using wget.

assert os.system('wget -q http://pub.htmd.org/tutorials/adaptive-sampling/ntl9_crystal.pdb') == 0

We can define a simple goal function that uses the RMSD between the conformation sampled and a reference (in this case, the crystal structure), and returns a score to be evaluated by the AdaptiveGoal algorithm:

ref = Molecule('./ntl9_crystal.pdb')

def mygoalfunction(mol):
    rmsd = MetricRmsd(ref, 'protein and name CA').project(mol)
    return -rmsd  # or even 1/rmsd

adg.goalfunction = mygoalfunction

AdaptiveGoal ranks conformations from a high to low score. For the case of RMSD, since we want lower RMSD to give higher score, the symetric value is returned instead (the inverse would also work).

Launch the AdaptiveGoal run:

adg.run()
2024-06-11 16:49:07,264 - htmd.adaptive.adaptive - INFO - Processing epoch 0
2024-06-11 16:49:07,265 - htmd.adaptive.adaptive - INFO - Epoch 0, generating first batch
2024-06-11 16:49:07,286 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0
2024-06-11 16:49:07,287 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1
2024-06-11 16:49:07,287 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0 on device 0
2024-06-11 16:49:07,288 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2
2024-06-11 16:49:07,289 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:51:07,308 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:51:07,309 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:51:07,309 - htmd.adaptive.adaptive - INFO - 3 simulations in progress
2024-06-11 16:51:07,310 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:51:18,374 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0
2024-06-11 16:51:18,375 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1 on device 0
2024-06-11 16:53:07,408 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:53:07,409 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:53:07,409 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 16:53:07,410 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:53:28,138 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1
2024-06-11 16:53:28,139 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2 on device 0
2024-06-11 16:55:07,508 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 16:55:07,509 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:55:07,510 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 16:55:07,510 - htmd.adaptive.adaptiverun - INFO - Postprocessing new data
Creating simlist: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:00<00:00, 1872.46it/s]
Filtering trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  3.81it/s]
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 409.90it/s]
2024-06-11 16:55:08,491 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 16:55:08,492 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
2024-06-11 16:55:08,976 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 37.06it/s]
2024-06-11 16:55:09,158 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 16:55:09,160 - htmd.adaptive.adaptiverun - WARNING - Using less macrostates than requested due to lack of microstates. macronum = 3
2024-06-11 16:55:09,299 - htmd.model - WARNING - PCCA returned empty macrostates. Reducing the number of macrostates to 2.
2024-06-11 16:55:09,301 - htmd.model - INFO - 100.0% of the data was used
2024-06-11 16:55:09,302 - htmd.model - INFO - Number of trajectories that visited each macrostate:
2024-06-11 16:55:09,302 - htmd.model - INFO - [2 2]
Writing inputs: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  6.22it/s]
2024-06-11 16:55:09,630 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s2p0f3
2024-06-11 16:55:09,630 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s2p0f4
2024-06-11 16:55:09,631 - htmd.adaptive.adaptive - INFO - Finished submitting simulations.
2024-06-11 16:55:09,631 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:55:37,450 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2
2024-06-11 16:55:37,451 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s2p0f3 on device 0
2024-06-11 16:57:09,729 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 16:57:09,730 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:57:09,731 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 16:57:09,731 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:57:48,099 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s2p0f3
2024-06-11 16:57:48,099 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s2p0f4 on device 0
2024-06-11 16:59:09,829 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 16:59:09,830 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 16:59:09,831 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 16:59:09,832 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 16:59:58,223 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s2p0f4
2024-06-11 17:01:09,870 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 17:01:09,878 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:01:09,879 - htmd.adaptive.adaptive - INFO - 0 simulations in progress
2024-06-11 17:01:09,880 - htmd.adaptive.adaptive - INFO - Reached maximum number of epochs 2

Functions with multiple arguments#

The goal function can also take multiple arguments. This allows flexibility and on-the-fly comparisons to non-static conformations (i.e.Β compare with different references as the run progresses). Here, we redefine the previous goal function with multiple arguments:

def newgoalfunction(mol, crystal):
    rmsd = MetricRmsd(crystal, 'protein and name CA').project(mol)
    return -rmsd  # or even 1/rmsd

Now we clean the previous AdaptiveGoal run, and start a new one with the new goal function:

# clean previous run
shutil.rmtree('./input')
shutil.rmtree('./data')
shutil.rmtree('./filtered')

# run with new goal
ref = Molecule('./ntl9_crystal.pdb')
adg.goalfunction = (newgoalfunction, (ref,))
adg.run()
2024-06-11 17:01:09,923 - htmd.adaptive.adaptive - INFO - Processing epoch 0
2024-06-11 17:01:09,924 - htmd.adaptive.adaptive - INFO - Epoch 0, generating first batch
2024-06-11 17:01:09,935 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0
2024-06-11 17:01:09,935 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1
2024-06-11 17:01:09,935 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0 on device 0
2024-06-11 17:01:09,936 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2
2024-06-11 17:01:09,936 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:03:10,040 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 17:03:10,049 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:03:10,050 - htmd.adaptive.adaptive - INFO - 3 simulations in progress
2024-06-11 17:03:10,050 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:03:39,489 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s1_ntl9_1ns_0
2024-06-11 17:03:39,495 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1 on device 0
2024-06-11 17:05:10,158 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 17:05:10,161 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:05:10,161 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 17:05:10,161 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:05:55,679 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s2_ntl9_1ns_1
2024-06-11 17:05:55,680 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2 on device 0
2024-06-11 17:07:10,260 - htmd.adaptive.adaptive - INFO - Processing epoch 1
2024-06-11 17:07:10,261 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:07:10,262 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 17:07:10,262 - htmd.adaptive.adaptiverun - INFO - Postprocessing new data
Creating simlist: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:00<00:00, 889.50it/s]
Filtering trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  3.99it/s]
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 438.14it/s]
2024-06-11 17:07:11,184 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 17:07:11,185 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
2024-06-11 17:07:11,757 - htmd.metricdata - INFO - Dropped 0 trajectories from 2 resulting in 2
Projecting trajectories: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 30.17it/s]
2024-06-11 17:07:11,857 - htmd.projections.metric - INFO - Frame step 0.1ns was read from the trajectories. If it looks wrong, redefine it by manually setting the MetricData.fstep property.
2024-06-11 17:07:11,859 - htmd.adaptive.adaptiverun - WARNING - Using less macrostates than requested due to lack of microstates. macronum = 3
2024-06-11 17:07:12,042 - htmd.model - INFO - 95.0% of the data was used
2024-06-11 17:07:12,043 - htmd.model - INFO - Number of trajectories that visited each macrostate:
2024-06-11 17:07:12,043 - htmd.model - INFO - [2 2]
Writing inputs: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00,  5.80it/s]
2024-06-11 17:07:12,394 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s1p0f5
2024-06-11 17:07:12,395 - jobqueues.localqueue - INFO - Queueing /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s1p0f5
2024-06-11 17:07:12,395 - htmd.adaptive.adaptive - INFO - Finished submitting simulations.
2024-06-11 17:07:12,395 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:08:06,459 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e1s3_ntl9_1ns_2
2024-06-11 17:08:06,460 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s1p0f5 on device 0
2024-06-11 17:09:12,492 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 17:09:12,493 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:09:12,493 - htmd.adaptive.adaptive - INFO - 2 simulations in progress
2024-06-11 17:09:12,494 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:10:16,325 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s1_e1s1p0f5
2024-06-11 17:10:16,325 - jobqueues.localqueue - INFO - Running /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s1p0f5 on device 0
2024-06-11 17:11:12,593 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 17:11:12,595 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:11:12,595 - htmd.adaptive.adaptive - INFO - 1 simulations in progress
2024-06-11 17:11:12,596 - htmd.adaptive.adaptive - INFO - Sleeping for 120 seconds.
2024-06-11 17:12:26,900 - jobqueues.localqueue - INFO - Completed /home/sdoerr/Work/htmd/tutorials/adaptivegoal/input/e2s2_e1s1p0f5
2024-06-11 17:13:12,625 - htmd.adaptive.adaptive - INFO - Processing epoch 2
2024-06-11 17:13:12,627 - htmd.adaptive.adaptive - INFO - Retrieving simulations.
2024-06-11 17:13:12,628 - htmd.adaptive.adaptive - INFO - 0 simulations in progress
2024-06-11 17:13:12,629 - htmd.adaptive.adaptive - INFO - Reached maximum number of epochs 2

Other goal function examples#

HTMD includes other two goal functions: The secondary structure goal function and the contacts goal function.

Secondary structure goal function#

ref = Molecule('./ntl9_crystal.pdb')

def ssGoal(mol, crystal):
    crystalSS = MetricSecondaryStructure().project(crystal)[0]
    proj = MetricSecondaryStructure().project(mol)
    # How many crystal SS match with simulation SS
    ss_score = np.sum(proj == crystalSS, axis=1) / proj.shape[1]
    return ss_score

adg.goalfunction = (ssGoal, (ref,))

Contacts goal function#

ref = Molecule('./ntl9_crystal.pdb')

def contactGoal(mol, crystal):
    crystalCO = MetricSelfDistance('protein and name CA', pbc=False,
                                   metric='contacts',
                                   threshold=10).project(crystal)
    proj = MetricSelfDistance('protein and name CA',
                              metric='contacts',
                              threshold=10).project(mol)
    # How many crystal contacts are seen?
    co_score = np.sum(proj[:, crystalCO] == 1, axis=1)
    co_score /= np.sum(crystalCO)
    return ss_score

adg.goalfunction = (contactGoal, (ref,))

Many more goal functions can be devised.