Wrong relative path to tests/data/test_isolate_* files

Issue #64 resolved
Peter Cock created an issue

The documentation in the main README file clearly says to run the tests as follows from the main ResFinder directory:

python3 tests/functional_tests.py

However, the code currently refers to test FASTA and FASTQ files via relative paths like data/test_isolate_01.fa - and the tests all fail. Running the individual commands shows error messages about this files not being found (because their path is wrong).

These should all be tests/data/test_isolate_01.fa and so on, or the code could adjust the paths depending where the tests are being run from (e.g. use self.dir_res and os.path.join or similar). Suggested fix:

$ git diff tests/functional_tests.py
diff --git a/tests/functional_tests.py b/tests/functional_tests.py
index 2843f30..12acb42 100755
--- a/tests/functional_tests.py
+++ b/tests/functional_tests.py
@@ -16,11 +16,11 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
 test_names = ["test1", "test2", "test3", "test4"]
 test_data = {
     # Test published acquired resistance
-    test_names[0]: "data/test_isolate_01.fa",
-    test_names[1]: "data/test_isolate_01_1.fq data/test_isolate_01_2.fq",
+    test_names[0]: "tests/data/test_isolate_01.fa",
+    test_names[1]: "tests/data/test_isolate_01_1.fq tests/data/test_isolate_01_2.fq",
     # Test published point mut resistance
-    test_names[2]: "data/test_isolate_05.fa",
-    test_names[3]: "data/test_isolate_05_1.fq data/test_isolate_05_2.fq",
+    test_names[2]: "tests/data/test_isolate_05.fa",
+    test_names[3]: "tests/data/test_isolate_05_1.fq tests/data/test_isolate_05_2.fq",
 }
 run_test_dir = "running_test"
 working_dir = os.path.dirname(os.path.realpath(__file__))

Comments (1)

  1. Peter Cock reporter

    Working now, unclear what I did wrong earlier in the week.

    Installation on 64-bit Linux with dependencies installed using conda (using conda-forge and bioconda channels):

    $ conda install blast kma tabulate biopython cgecore gitpython python-dateutil
    

    Key dependency versions:

    $ python3 --version
    Python 3.7.9
    $ kma -v
    KMA-1.3.28
    $ blastn -version
    blastn: 2.12.0+
     Package: blast 2.12.0, build Jul 13 2021 09:03:00
    

    Using version 4.1.6 from github:

    $ git clone https://git@bitbucket.org/genomicepidemiology/resfinder.git
    $ cd resfinder
    $ git checkout 4.1.6
    

    Databases installed as per https://bitbucket.org/genomicepidemiology/resfinder/src/master/README.md documentation,

    $ git clone https://git@bitbucket.org/genomicepidemiology/resfinder_db.git db_resfinder
    $ cd db_resfinder
    $ python3 INSTALL.py
    $ cd .. 
    

    and:

    $ git clone https://git@bitbucket.org/genomicepidemiology/pointfinder_db.git db_pointfinder
    $ cd db_pointfinder
    $ python3 INSTALL.py
    $ cd ..
    

    Sadly the test suite does not default to blastn and kma being on the path (that might need to change for a conda installation), but we can specify their location:

    $ python3 tests/functional_tests.py -b `which blastn` -k `which kma`
    ....
    ----------------------------------------------------------------------
    Ran 4 tests in 54.526s
    
    OK
    
  2. Log in to comment