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
2eb2c464
Unverified
Commit
2eb2c464
authored
Nov 22, 2017
by
peastman
Committed by
GitHub
Nov 22, 2017
Browse files
Merge pull request #1938 from peastman/includes
Improvement to processing of includes in force fields
parents
b7fbe622
4111024b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
docs-source/usersguide/application.rst
docs-source/usersguide/application.rst
+0
-6
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+13
-8
No files found.
docs-source/usersguide/application.rst
View file @
2eb2c464
...
@@ -2959,12 +2959,6 @@ relative either to the directory containing the parent XML file (the one with
...
@@ -2959,12 +2959,6 @@ relative either to the directory containing the parent XML file (the one with
the
:
code
:`<
Include
>`
tag
)
or
the
OpenMM
data
directory
(
the
one
containing
the
:
code
:`<
Include
>`
tag
)
or
the
OpenMM
data
directory
(
the
one
containing
built
in
force
fields
).
built
in
force
fields
).
The
included
file
is
fully
processed
before
any
other
tags
in
the
parent
file
are
processed
,
and
its
definitions
are
added
to
the
force
field
.
This
means
the
parent
file
can
refer
to
atom
types
defined
in
the
included
file
,
but
not
the
other
way
around
.
If
there
are
multiple
:
code
:`<
Include
>`
tags
,
they
are
processed
in
the
order
they
appear
in
the
file
.
Using
Multiple
Files
Using
Multiple
Files
********************
********************
...
...
wrappers/python/simtk/openmm/app/forcefield.py
View file @
2eb2c464
...
@@ -190,12 +190,16 @@ class ForceField(object):
...
@@ -190,12 +190,16 @@ class ForceField(object):
method from which the forcefield XML data can be loaded.
method from which the forcefield XML data can be loaded.
"""
"""
if
not
isinstance
(
files
,
tuple
):
if
isinstance
(
files
,
tuple
):
files
=
(
files
,)
files
=
list
(
files
)
else
:
files
=
[
files
]
trees
=
[]
trees
=
[]
for
file
in
files
:
i
=
0
while
i
<
len
(
files
):
file
=
files
[
i
]
tree
=
None
tree
=
None
try
:
try
:
# this handles either filenames or open file-like objects
# this handles either filenames or open file-like objects
...
@@ -221,12 +225,12 @@ class ForceField(object):
...
@@ -221,12 +225,12 @@ class ForceField(object):
raise
ValueError
(
'Could not locate file "%s"'
%
file
)
raise
ValueError
(
'Could not locate file "%s"'
%
file
)
trees
.
append
(
tree
)
trees
.
append
(
tree
)
i
+=
1
# Process includes.
# Process includes
in this file
.
for
parentFile
,
tree
in
zip
(
files
,
trees
):
if
isinstance
(
file
,
str
):
if
isinstance
(
parentFile
,
str
):
parentDir
=
os
.
path
.
dirname
(
file
)
parentDir
=
os
.
path
.
dirname
(
parentFile
)
else
:
else
:
parentDir
=
''
parentDir
=
''
for
include
in
tree
.
getroot
().
findall
(
'Include'
):
for
include
in
tree
.
getroot
().
findall
(
'Include'
):
...
@@ -234,7 +238,8 @@ class ForceField(object):
...
@@ -234,7 +238,8 @@ class ForceField(object):
joined
=
os
.
path
.
join
(
parentDir
,
includeFile
)
joined
=
os
.
path
.
join
(
parentDir
,
includeFile
)
if
os
.
path
.
isfile
(
joined
):
if
os
.
path
.
isfile
(
joined
):
includeFile
=
joined
includeFile
=
joined
self
.
loadFile
(
includeFile
)
if
includeFile
not
in
files
:
files
.
append
(
includeFile
)
# Load the atom types.
# Load the atom types.
...
...
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