Skip to content

Commit

Permalink
Merge pull request #86 from Becksteinlab/issue-85-find_gromacs_command
Browse files Browse the repository at this point in the history
fixed find_gromacs_command()
  • Loading branch information
orbeckst authored Sep 9, 2016
2 parents 1328b41 + 1ab89cb commit 69cb158
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ install:

# run tests
script:
- py.test --cov gromacs
- py.test --cov gromacs gromacs/tests

after_success:
- codecov
21 changes: 10 additions & 11 deletions gromacs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ def find_gromacs_command(commands):
# We could try executing 'name' or 'driver name' but to keep things lean we
# just check if the executables can be found and then hope for the best.

for command in utilities.asiterable(commands):
if command.find(':') != -1:
driver = command.split(':')[0]
name = command.split(':')[1]
if utilities.which(driver):
break
else:
driver = None
name = command
if utilities.which(name):
break
commands = utilities.asiterable(commands)
for command in commands:
try:
driver, name = command.split()
except ValueError:
driver, name = None, command

executable = driver if driver else name
if utilities.which(executable):
break
else:
raise OSError(errno.ENOENT, "No Gromacs executable found in", ", ".join(commands))

Expand Down
4 changes: 3 additions & 1 deletion gromacs/tests/fileformats/top/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from numpy.testing import assert_array_equal, assert_
from pandas.util.testing import assert_frame_equal

import pytest

import gromacs
from gromacs.fileformats import TOP, XVG
from gromacs.scaling import partial_tempering
Expand Down Expand Up @@ -54,7 +56,7 @@ class Namespace(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)


@pytest.mark.skip(reason="Not currently maintained. See #61.")
class TopologyTest(object):
grompp = 'fileformats/top/grompp.mdp'
def test_basic(self):
Expand Down
16 changes: 16 additions & 0 deletions gromacs/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import division, absolute_import, print_function

import pytest
from unittest import TestCase

from .datafiles import datafile
Expand Down Expand Up @@ -44,5 +45,20 @@ def test_MDRunner():
rc = mdrun.run(mdrunargs={'version': True})
assert(rc == 0)

class Test_find_gromacs_command(TestCase):
# Gromacs 4 or Gromacs 5 (in this order)
commands = ["grompp", "gmx grompp"]

def test_find(self):
driver, name = gromacs.run.find_gromacs_command(self.commands)
assert (driver in (None, "gmx"),
"find_gromacs_command() did not identify a driver")
assert (name == self.commands[0],
"find_gromacs_command() did not find a command")


@staticmethod
def test_raises_ValueError():
with pytest.raises(OSError):
driver, name = gromacs.run.find_gromacs_command(["./not_a_command"])

0 comments on commit 69cb158

Please sign in to comment.