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
167253d5
Commit
167253d5
authored
Sep 26, 2013
by
Yutong Zhao
Browse files
Merge pull request #149 from rmcgibbo/gmxpath
Look for gromacs include directory in a more flexible way
parents
02adeefa
4537062c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
wrappers/python/simtk/openmm/app/gromacstopfile.py
wrappers/python/simtk/openmm/app/gromacstopfile.py
+24
-3
No files found.
wrappers/python/simtk/openmm/app/gromacstopfile.py
View file @
167253d5
...
@@ -40,6 +40,7 @@ import simtk.unit as unit
...
@@ -40,6 +40,7 @@ import simtk.unit as unit
import
simtk.openmm
as
mm
import
simtk.openmm
as
mm
import
math
import
math
import
os
import
os
import
distutils
HBonds
=
ff
.
HBonds
HBonds
=
ff
.
HBonds
AllBonds
=
ff
.
AllBonds
AllBonds
=
ff
.
AllBonds
...
@@ -342,16 +343,20 @@ class GromacsTopFile(object):
...
@@ -342,16 +343,20 @@ class GromacsTopFile(object):
raise
ValueError
(
'Unsupported function type in [ cmaptypes ] line: '
+
line
);
raise
ValueError
(
'Unsupported function type in [ cmaptypes ] line: '
+
line
);
self
.
_cmapTypes
[
tuple
(
fields
[:
5
])]
=
fields
self
.
_cmapTypes
[
tuple
(
fields
[:
5
])]
=
fields
def
__init__
(
self
,
file
,
unitCellDimensions
=
None
,
includeDir
=
'/usr/local/gromacs/share/gromacs/top'
,
defines
=
{}):
def
__init__
(
self
,
file
,
unitCellDimensions
=
None
,
includeDir
=
None
,
defines
=
{}):
"""Load a top file.
"""Load a top file.
Parameters:
Parameters:
- file (string) the name of the file to load
- file (string) the name of the file to load
- unitCellDimensions (Vec3=None) the dimensions of the crystallographic unit cell
- unitCellDimensions (Vec3=None) the dimensions of the crystallographic unit cell
- includeDir (string=/usr/local/gromacs/share/gromacs/top) a directory in which to look for other files
- includeDir (string=None) A directory in which to look for other files
included from the top file
included from the top file. If not specified, we will attempt to locate a gromacs
installation on your system. When gromacs is installed in /usr/local, this will resolve
to /usr/local/gromacs/share/gromacs/top
- defines (map={}) preprocessor definitions that should be predefined when parsing the file
- defines (map={}) preprocessor definitions that should be predefined when parsing the file
"""
"""
if
includeDir
is
None
:
includeDir
=
_defaultGromacsIncludeDir
()
self
.
_includeDirs
=
(
os
.
path
.
dirname
(
file
),
includeDir
)
self
.
_includeDirs
=
(
os
.
path
.
dirname
(
file
),
includeDir
)
self
.
_defines
=
defines
self
.
_defines
=
defines
...
@@ -752,3 +757,19 @@ class GromacsTopFile(object):
...
@@ -752,3 +757,19 @@ class GromacsTopFile(object):
if
removeCMMotion
:
if
removeCMMotion
:
sys
.
addForce
(
mm
.
CMMotionRemover
())
sys
.
addForce
(
mm
.
CMMotionRemover
())
return
sys
return
sys
def
_defaultGromacsIncludeDir
():
"""Find the location where gromacs #include files are referenced from, by
searching for (1) gromacs environment variables, (2) for the gromacs binary
'pdb2gmx' in the PATH, or (3) just using the default gromacs install
location, /usr/local/gromacs/share/gromacs/top """
if
'GMXDATA'
in
os
.
environ
:
return
os
.
path
.
join
(
os
.
environ
[
'GMXDATA'
],
'top'
)
if
'GMXBIN'
in
os
.
environ
:
return
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
environ
[
'GMXBIN'
],
'..'
,
'share'
,
'gromacs'
,
'top'
))
pdb2gmx_path
=
distutils
.
spawn
.
find_executable
(
'pdb2gmx'
)
if
pdb2gmx_path
is
not
None
:
return
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
pdb2gmx_path
),
'..'
,
'share'
,
'gromacs'
,
'top'
))
return
'/usr/local/gromacs/share/gromacs/top'
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