Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdbfixer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pdbfixer
Commits
24ca9600
Commit
24ca9600
authored
Mar 28, 2014
by
John Chodera (MSKCC)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added simulation test, and cleaned up tests a bit.
We still only test one PDB file, however.
parent
fc191ebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
7 deletions
+83
-7
tests/test_build.py
+12
-3
tests/test_simulate.py
+71
-4
No files found.
tests/test_build.py
View file @
24ca9600
from
Bio.PDB
import
PDBList
from
simtk
import
unit
import
pdbfixer
from
pdbfixer.pdbfixer
import
*
import
simtk.openmm
import
Bio.PDB
import
os
import
os
import
sys
import
sys
import
numpy
def
test_build
():
def
test_build
():
# These are tough PDB codes from http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/badpdbs.htm
# These are tough PDB codes from http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/badpdbs.htm
...
@@ -10,6 +13,7 @@ def test_build():
...
@@ -10,6 +13,7 @@ def test_build():
pdbcodes
=
[
'1VII'
]
# DEBUG: just use one
pdbcodes
=
[
'1VII'
]
# DEBUG: just use one
# Set up PDB retrieval.
# Set up PDB retrieval.
from
Bio.PDB
import
PDBList
pdblist
=
PDBList
(
server
=
PDBList
.
alternative_download_url
)
pdblist
=
PDBList
(
server
=
PDBList
.
alternative_download_url
)
success
=
True
success
=
True
...
@@ -29,6 +33,7 @@ def test_build():
...
@@ -29,6 +33,7 @@ def test_build():
# PDB setup parameters.
# PDB setup parameters.
# TODO: Try several combinations?
# TODO: Try several combinations?
from
simtk
import
unit
pH
=
7.0
pH
=
7.0
ionic
=
50.0
*
unit
.
millimolar
ionic
=
50.0
*
unit
.
millimolar
box
=
10.0
*
unit
.
angstrom
box
=
10.0
*
unit
.
angstrom
...
@@ -39,6 +44,8 @@ def test_build():
...
@@ -39,6 +44,8 @@ def test_build():
outfile
=
open
(
output_pdb_filename
,
'w'
)
outfile
=
open
(
output_pdb_filename
,
'w'
)
try
:
try
:
from
pdbfixer.pdbfixer
import
PDBFixer
,
PdbStructure
from
simtk.openmm
import
app
fixer
=
PDBFixer
(
PdbStructure
(
infile
))
fixer
=
PDBFixer
(
PdbStructure
(
infile
))
fixer
.
findMissingResidues
()
fixer
.
findMissingResidues
()
fixer
.
findNonstandardResidues
()
fixer
.
findNonstandardResidues
()
...
@@ -63,3 +70,5 @@ def test_build():
...
@@ -63,3 +70,5 @@ def test_build():
if
not
success
:
if
not
success
:
raise
Exception
(
"build test failed on one or more PDB files."
)
raise
Exception
(
"build test failed on one or more PDB files."
)
if
__name__
==
'__main__'
:
test_build
()
tests/test_simulate.py
View file @
24ca9600
from
Bio.PDB
import
PDBList
from
simtk
import
unit
import
pdbfixer
from
pdbfixer.pdbfixer
import
*
import
simtk.openmm
import
Bio.PDB
import
os
import
os
import
sys
import
sys
import
numpy
def
simulate
(
pdbcode
,
pdb_filename
):
from
simtk.openmm
import
app
import
simtk.openmm
as
mm
from
simtk
import
unit
from
sys
import
stdout
# Load the PDB file.
pdb
=
app
.
PDBFile
(
pdb_filename
)
# Set up implicit solvent forcefield.
forcefield
=
app
.
ForceField
(
'amber99sbildn.xml'
,
'amber99_obc.xml'
)
# Create the system.
system
=
forcefield
.
createSystem
(
pdb
.
topology
,
nonbondedMethod
=
app
.
NoCutoff
,
constraints
=
app
.
HBonds
)
# Create an integrator.
integrator
=
mm
.
LangevinIntegrator
(
300
*
unit
.
kelvin
,
91.0
/
unit
.
picoseconds
,
1.0
*
unit
.
femtoseconds
)
# Create a context.
context
=
mm
.
Context
(
system
,
integrator
)
context
.
setPositions
(
pdb
.
positions
)
# Check to make sure energy is finite.
state
=
context
.
getState
(
getEnergy
=
True
)
potential
=
state
.
getPotentialEnergy
()
/
unit
.
kilocalories_per_mole
if
numpy
.
isnan
(
potential
):
raise
Exception
(
"Initial energy for
%
s is NaN."
%
pdbcode
)
# Minimize.
tolerance
=
1.0
*
unit
.
kilocalories_per_mole
/
unit
.
angstroms
maxIterations
=
50
mm
.
LocalEnergyMinimizer
.
minimize
(
context
,
tolerance
,
maxIterations
)
def
test_build
():
# Check to make sure energy is finite.
state
=
context
.
getState
(
getEnergy
=
True
)
potential
=
state
.
getPotentialEnergy
()
/
unit
.
kilocalories_per_mole
if
numpy
.
isnan
(
potential
):
raise
Exception
(
"Energy for
%
s is NaN after minimization."
%
pdbcode
)
# Simulate.
nsteps
=
500
integrator
.
step
(
nsteps
)
# Check to make sure energy is finite.
state
=
context
.
getState
(
getEnergy
=
True
)
potential
=
state
.
getPotentialEnergy
()
/
unit
.
kilocalories_per_mole
if
numpy
.
isnan
(
potential
):
raise
Exception
(
"Energy for
%
s is NaN after simulation."
%
pdbcode
)
del
context
,
integrator
print
"Simulation completed: potential =
%.3
f kcal/mol"
%
potential
return
def
test_simulate
():
# These are tough PDB codes from http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/badpdbs.htm
# These are tough PDB codes from http://www.umass.edu/microbio/chime/pe_beta/pe/protexpl/badpdbs.htm
pdbcodes
=
[
'1AS5'
,
'1CBN'
,
'1DPO'
,
'1IGY'
,
'1HAG'
,
'1IAO'
,
'4CPA'
,
'1QCQ'
]
pdbcodes
=
[
'1AS5'
,
'1CBN'
,
'1DPO'
,
'1IGY'
,
'1HAG'
,
'1IAO'
,
'4CPA'
,
'1QCQ'
]
pdbcodes
=
[
'1VII'
]
# DEBUG: just use one
pdbcodes
=
[
'1VII'
]
# DEBUG: just use one
# Set up PDB retrieval.
# Set up PDB retrieval.
from
Bio.PDB
import
PDBList
pdblist
=
PDBList
(
server
=
PDBList
.
alternative_download_url
)
pdblist
=
PDBList
(
server
=
PDBList
.
alternative_download_url
)
success
=
True
success
=
True
...
@@ -29,6 +88,7 @@ def test_build():
...
@@ -29,6 +88,7 @@ def test_build():
# PDB setup parameters.
# PDB setup parameters.
# TODO: Try several combinations?
# TODO: Try several combinations?
from
simtk
import
unit
pH
=
7.0
pH
=
7.0
ionic
=
50.0
*
unit
.
millimolar
ionic
=
50.0
*
unit
.
millimolar
box
=
10.0
*
unit
.
angstrom
box
=
10.0
*
unit
.
angstrom
...
@@ -39,6 +99,8 @@ def test_build():
...
@@ -39,6 +99,8 @@ def test_build():
outfile
=
open
(
output_pdb_filename
,
'w'
)
outfile
=
open
(
output_pdb_filename
,
'w'
)
try
:
try
:
from
pdbfixer.pdbfixer
import
PDBFixer
,
PdbStructure
from
simtk.openmm
import
app
fixer
=
PDBFixer
(
PdbStructure
(
infile
))
fixer
=
PDBFixer
(
PdbStructure
(
infile
))
fixer
.
findMissingResidues
()
fixer
.
findMissingResidues
()
fixer
.
findNonstandardResidues
()
fixer
.
findNonstandardResidues
()
...
@@ -52,6 +114,9 @@ def test_build():
...
@@ -52,6 +114,9 @@ def test_build():
infile
.
close
()
infile
.
close
()
outfile
.
close
()
outfile
.
close
()
# Test simulating this with OpenMM.
simulate
(
pdbcode
,
output_pdb_filename
)
# Delete input file.
# Delete input file.
os
.
remove
(
input_pdb_filename
)
os
.
remove
(
input_pdb_filename
)
os
.
remove
(
output_pdb_filename
)
os
.
remove
(
output_pdb_filename
)
...
@@ -63,3 +128,5 @@ def test_build():
...
@@ -63,3 +128,5 @@ def test_build():
if
not
success
:
if
not
success
:
raise
Exception
(
"build test failed on one or more PDB files."
)
raise
Exception
(
"build test failed on one or more PDB files."
)
if
__name__
==
'__main__'
:
test_simulate
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment