Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
6f1db1fb
Unverified
Commit
6f1db1fb
authored
Apr 30, 2018
by
peastman
Committed by
GitHub
Apr 30, 2018
Browse files
Merge pull request #2054 from peastman/forcefielddir
Improved behavior of adding force field directories
parents
72def6fb
ac27d6b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+15
-9
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
6f1db1fb
...
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
...
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for
Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org.
Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2012-201
7
Stanford University and the Authors.
Portions copyright (c) 2012-201
8
Stanford University and the Authors.
Authors: Peter Eastman, Mark Friedrichs
Authors: Peter Eastman, Mark Friedrichs
Contributors:
Contributors:
...
@@ -49,13 +49,19 @@ from simtk.openmm.app.internal.singleton import Singleton
...
@@ -49,13 +49,19 @@ from simtk.openmm.app.internal.singleton import Singleton
# Directories from which to load built in force fields.
# Directories from which to load built in force fields.
_dataDirectories
=
[
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
)]
_dataDirectories
=
None
try
:
from
pkg_resources
import
iter_entry_points
def
_getDataDirectories
():
for
entry
in
iter_entry_points
(
group
=
'openmm.forcefielddir'
):
global
_dataDirectories
_dataDirectories
.
append
(
entry
.
load
()())
if
_dataDirectories
is
None
:
except
:
_dataDirectories
=
[
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
)]
pass
# pkg_resources is not installed
try
:
from
pkg_resources
import
iter_entry_points
for
entry
in
iter_entry_points
(
group
=
'openmm.forcefielddir'
):
_dataDirectories
.
append
(
entry
.
load
()())
except
:
pass
# pkg_resources is not installed
return
_dataDirectories
def
_convertParameterToNumber
(
param
):
def
_convertParameterToNumber
(
param
):
if
unit
.
is_quantity
(
param
):
if
unit
.
is_quantity
(
param
):
...
@@ -205,7 +211,7 @@ class ForceField(object):
...
@@ -205,7 +211,7 @@ class ForceField(object):
# this handles either filenames or open file-like objects
# this handles either filenames or open file-like objects
tree
=
etree
.
parse
(
file
)
tree
=
etree
.
parse
(
file
)
except
IOError
:
except
IOError
:
for
dataDir
in
_
d
ataDirectories
:
for
dataDir
in
_
getD
ataDirectories
()
:
f
=
os
.
path
.
join
(
dataDir
,
file
)
f
=
os
.
path
.
join
(
dataDir
,
file
)
if
os
.
path
.
isfile
(
f
):
if
os
.
path
.
isfile
(
f
):
tree
=
etree
.
parse
(
f
)
tree
=
etree
.
parse
(
f
)
...
...
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