Skip to content

Commit

Permalink
Merge pull request #55 from jhprinz/tests
Browse files Browse the repository at this point in the history
Tests
  • Loading branch information
jhprinz authored May 26, 2017
2 parents 446e6cb + 802be3b commit 186ffa0
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 238 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# adaptive-sampling
# adaptiveMD
A Python framework to run adaptive Markov state model (MSM) simulation on HPC resources

The generation of MSMs requires a huge amount of trajectory data to be analyzed. In most cases
Expand Down Expand Up @@ -91,6 +91,9 @@ python setup.py develop
# see if it works
python -c "import adaptivemd" || echo 'FAILED'

# run the mongodb server if not running already
mongod --dbpath={path_to_your_db_folder}

# run a simple test
cd adaptive/tests/
python test_simple.py
Expand All @@ -99,7 +102,7 @@ python test_simple.py

All of this must also be installed on the cluster, where you want to run your simulations.

For allegro I suggest to use a miniconda installation. Note that you only need these packages if you want to use some of it on the cluster like run openmm or make computations using pyemma. Just for running, say `acemd` conda is not required!
For allegro I suggest to use a miniconda installation. Note that you only need these packages if you want to use some of it on the cluster like run openmm or make computations using pyemma. Just for running, say `acemd`, conda is not required!

That's it. Have fun running adaptive simulations.

Expand Down
32 changes: 18 additions & 14 deletions adaptivemd/tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,51 +66,55 @@
pdb = md.load('../../examples/files/alanine/alanine.pdb')
cwd = os.getcwd()

# this part fakes a running worker without starting the worker process
worker = WorkerScheduler(project.resource)
worker.enter(project)
# we are using only the scheduling and excution logic, not a real
# separate worker task
scheduler = WorkerScheduler(project.resource)
scheduler.enter(project)

worker.submit(task)
scheduler(task)

assert(len(project.trajectories) == 0)

while not task.is_done():
worker.advance()
scheduler.advance()

assert(len(project.trajectories) == 1)

traj_path = os.path.join(
worker.path,
'workers',
'worker.' + hex(task.__uuid__),
worker.replace_prefix(project.trajectories.one.url)
scheduler.path,
'projects',
'example-simple-1',
'trajs',
'00000000',
'output.dcd'
)

assert(os.path.exists(traj_path))

# go back to the place where we ran the test
traj = md.load(traj_path, top=pdb)

assert(len(traj) == 100)
# 100 simulation steps + initial one should be 101 frames long
assert(len(traj) == 101)

# well, we have a 100 step trajectory which matches the size of the initial PDB
# that is a good sign

# extend the trajectory by 50
task2 = task.extend(50)

worker.submit(task2)
scheduler.submit(task2)

while not task2.is_done():
worker.advance()
scheduler.advance()

# should still be one, since we have the same trajectory
assert(len(project.trajectories) == 1)

traj = md.load(traj_path, top=pdb)

assert (len(traj) == 150)
assert (len(traj) == 151)

# after extension it is 150 frames. Excellent
# after extension it is 101 + 50 = 151 frames. Excellent

project.close()
65 changes: 38 additions & 27 deletions examples/tutorial/1_example_setup_project.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 5,
"metadata": {
"collapsed": false
},
Expand All @@ -132,7 +132,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {
"collapsed": false
},
Expand All @@ -150,7 +150,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {
"collapsed": false
},
Expand All @@ -161,7 +161,7 @@
"'$HOME/adaptivemd/'"
]
},
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -197,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 8,
"metadata": {
"collapsed": false
},
Expand All @@ -215,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 9,
"metadata": {
"collapsed": true
},
Expand All @@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 10,
"metadata": {
"collapsed": false
},
Expand All @@ -265,7 +265,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"collapsed": true
},
Expand All @@ -283,11 +283,22 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'alanine.pdb'"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pdb_file.load()"
]
Expand Down Expand Up @@ -320,7 +331,7 @@
},
{
"cell_type": "code",
"execution_count": 48,
"execution_count": 13,
"metadata": {
"collapsed": true
},
Expand All @@ -345,7 +356,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 14,
"metadata": {
"collapsed": false
},
Expand All @@ -370,7 +381,7 @@
},
{
"cell_type": "code",
"execution_count": 50,
"execution_count": 15,
"metadata": {
"collapsed": false
},
Expand All @@ -381,7 +392,7 @@
"'openmm'"
]
},
"execution_count": 50,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -401,7 +412,7 @@
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 16,
"metadata": {
"collapsed": false
},
Expand All @@ -420,7 +431,7 @@
},
{
"cell_type": "code",
"execution_count": 52,
"execution_count": 17,
"metadata": {
"collapsed": true
},
Expand All @@ -438,7 +449,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 18,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -485,7 +496,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 19,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -546,7 +557,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 20,
"metadata": {
"collapsed": false
},
Expand All @@ -557,7 +568,7 @@
"Trajectory('alanine.pdb' >> [0..100])"
]
},
"execution_count": 56,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -596,7 +607,7 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 21,
"metadata": {
"collapsed": false
},
Expand All @@ -622,7 +633,7 @@
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 22,
"metadata": {
"collapsed": false
},
Expand All @@ -631,7 +642,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Frame(sandbox:///{}/00000001/[20])\n"
"Frame(sandbox:///{}/00000000/[20])\n"
]
}
],
Expand All @@ -648,7 +659,7 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": 23,
"metadata": {
"collapsed": false
},
Expand All @@ -657,7 +668,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<adaptivemd.engine.engine.TrajectoryExtensionTask object at 0x110e6e210>\n"
"<adaptivemd.engine.engine.TrajectoryExtensionTask object at 0x112c757d0>\n"
]
}
],
Expand All @@ -674,7 +685,7 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 24,
"metadata": {
"collapsed": false
},
Expand All @@ -683,7 +694,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<adaptivemd.engine.engine.TrajectoryGenerationTask object at 0x110dd46d0>\n"
"<adaptivemd.engine.engine.TrajectoryGenerationTask object at 0x112c75450>\n"
]
}
],
Expand Down
Loading

0 comments on commit 186ffa0

Please sign in to comment.