diff options
author | zsloan | 2021-06-18 17:33:09 -0500 |
---|---|---|
committer | GitHub | 2021-06-18 17:33:09 -0500 |
commit | d653a635d0efd2291754c18f51d31f91a1c0a25c (patch) | |
tree | 309ea800da204f721e92ebc1c725144eab939d0f /tests | |
parent | c553b52e140de1d7e5ed49f07bae2f4a120266f8 (diff) | |
parent | f7becfa11ca857104ecc1b668b4bd3d0a721083c (diff) | |
download | genenetwork3-d653a635d0efd2291754c18f51d31f91a1c0a25c.tar.gz |
Merge pull request #13 from zsloan/feature/add_rqtl_endpoints
Feature/add rqtl endpoints
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/computations/test_rqtl.py | 42 | ||||
-rw-r--r-- | tests/unit/test_commands.py | 25 |
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/unit/computations/test_rqtl.py b/tests/unit/computations/test_rqtl.py new file mode 100644 index 0000000..955d0ab --- /dev/null +++ b/tests/unit/computations/test_rqtl.py @@ -0,0 +1,42 @@ +"""Test cases for procedures defined in computations.rqtl""" +import unittest + +from unittest import mock +from gn3.computations.rqtl import generate_rqtl_cmd + +class TestRqtl(unittest.TestCase): + """Test cases for computations.rqtl module""" + @mock.patch("gn3.computations.rqtl.generate_hash_of_string") + @mock.patch("gn3.computations.rqtl.get_hash_of_files") + def test_generate_rqtl_command(self, mock_get_hash_files, mock_generate_hash_string): + """Test computing mapping results with R/qtl""" + mock_get_hash_files.return_value = "my-hash1" + mock_generate_hash_string.return_value = "my-hash2" + + self.assertEqual( + generate_rqtl_cmd(rqtl_wrapper_cmd="rqtl-wrapper", + rqtl_wrapper_kwargs={ + "g": "genofile", + "p": "phenofile", + "model": "normal", + "method": "hk", + "nperm": 1000, + "scale": "Mb", + "control": "rs123456" + }, + rqtl_wrapper_bool_kwargs=[ + "addcovar", + "interval" + ]), { + "output_file": + "my-hash1my-hash2my-hash2-output.csv", + "rqtl_cmd": ( + "Rscript rqtl-wrapper " + "--g genofile --p phenofile " + "--model normal --method hk " + "--nperm 1000 --scale Mb " + "--control rs123456 " + "--filename my-hash1my-hash2my-hash2-output.csv " + "--addcovar --interval" + ) + }) diff --git a/tests/unit/test_commands.py b/tests/unit/test_commands.py index aafb3a2..f36ba55 100644 --- a/tests/unit/test_commands.py +++ b/tests/unit/test_commands.py @@ -6,6 +6,7 @@ from datetime import datetime from typing import Callable from unittest import mock from gn3.commands import compose_gemma_cmd +from gn3.commands import compose_rqtl_cmd from gn3.commands import queue_cmd from gn3.commands import run_cmd from gn3.exceptions import RedisConnectionError @@ -53,6 +54,30 @@ class TestCommands(unittest.TestCase): "-p /tmp/gf13Ad0tRX/phenofile.txt" " -gk")) + def test_compose_rqtl_cmd(self): + """Test that the R/qtl cmd is composed correctly""" + self.assertEqual( + compose_rqtl_cmd(rqtl_wrapper_cmd="rqtl-wrapper", + rqtl_wrapper_kwargs={ + "g": "the_genofile", + "p": "the_phenofile", + "model": "np", + "method": "ehk", + "nperm": 2000, + "scale": "Mb", + "control": "rs234567" + }, + rqtl_wrapper_bool_kwargs=[ + "addcovar" + ]), + ("Rscript rqtl-wrapper " + "--g the_genofile --p the_phenofile " + "--model np --method ehk " + "--nperm 2000 --scale Mb " + "--control rs234567 " + "--addcovar") + ) + def test_queue_cmd_exception_raised_when_redis_is_down(self): """Test that the correct error is raised when Redis is unavailable""" self.assertRaises(RedisConnectionError, |