diff --git a/modules/bindings/pymod/naccess.py b/modules/bindings/pymod/naccess.py index 621067e7b8c68f2242cfbf047b0932d05b24ebd9..268b72ac141152bcbdb60be58be6dfb021b880b2 100644 --- a/modules/bindings/pymod/naccess.py +++ b/modules/bindings/pymod/naccess.py @@ -60,9 +60,9 @@ def _SetupFiles(entity, selection, scratch_dir, max_number_of_atoms): raise RuntimeError, "Could not create view for selection (%s)"%(selection) # write entity to tmp file - tmp_file_name=os.path.join(tmp_dir_name,"entity.pdb") + tmp_file_name = "entity.pdb" tmp_file_base = os.path.join(tmp_dir_name,"entity") - io.SavePDB(entity_view, tmp_file_name) + io.SavePDB(entity_view, os.path.join(tmp_dir_name, tmp_file_name)) return (tmp_dir_name, tmp_file_name, tmp_file_base) diff --git a/modules/bindings/tests/CMakeLists.txt b/modules/bindings/tests/CMakeLists.txt index c443de13285adf6a7818926e29d540a258c2580c..dd257c1cb9819c3f71233d22216537ba9b68d6b9 100644 --- a/modules/bindings/tests/CMakeLists.txt +++ b/modules/bindings/tests/CMakeLists.txt @@ -4,6 +4,7 @@ set(OST_BINDINGS_UNIT_TESTS test_hhblits.py test_blast.py test_kclust.py + test_naccess.py ) ost_unittest(MODULE bindings diff --git a/modules/bindings/tests/test_naccess.py b/modules/bindings/tests/test_naccess.py new file mode 100644 index 0000000000000000000000000000000000000000..891f01bd75aa104edd0d8431fa5480f04250958b --- /dev/null +++ b/modules/bindings/tests/test_naccess.py @@ -0,0 +1,42 @@ +''' Unit tests for the Naccess wrapper +''' + +import unittest +import os +import sys +import shutil +import tempfile + +from ost.bindings import naccess +from ost import io + +class TestNaccessBindings(unittest.TestCase): + def testTempDirWithDot(self): + # naccess itself has problems with '.' in the path. So we need to test + # that it works when data is used which has a correpsonding path. + na_tmp_dir = tempfile.mkdtemp(prefix="ih.") + def cleanup(): + shutil.rmtree(na_tmp_dir) + self.addCleanup(cleanup) + na_bin = os.path.join(os.getenv('EBROOTNACCESS'), 'naccess') + ost_ent = io.LoadPDB('testfiles/testprotein.pdb') + excp_raised = False + try: + sasa = naccess.CalculateSurfaceArea(ost_ent, + scratch_dir=na_tmp_dir, + naccess_exe=na_bin) + except: + excp_raised = True + raise + self.assertEquals(excp_raised, False, msg="Naccess raised an "+ + "exception on a path containing a '.'. This is not "+ + "supposed to happen.") + +if __name__ == "__main__": + naccess_dir = os.getenv('EBROOTNACCESS') + if not naccess_dir: + print "No environment variable 'EBROOTNACCESS'. To enable the "+\ + "unit test, this needs to point to your Naccess installation." + sys.exit(0) + from ost import testutils + testutils.RunTests()