From 5745c3bdd086f7c499ee63a580df822db5af2826 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 18 May 2021 19:43:50 +0000 Subject: Added unit test for computations/rqtl.py --- tests/unit/computations/test_rqtl.py | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/unit/computations/test_rqtl.py (limited to 'tests/unit/computations/test_rqtl.py') diff --git a/tests/unit/computations/test_rqtl.py b/tests/unit/computations/test_rqtl.py new file mode 100644 index 0000000..b16f136 --- /dev/null +++ b/tests/unit/computations/test_rqtl.py @@ -0,0 +1,41 @@ +"""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.json", + "rqtl_cmd": ( + "rqtl-wrapper " + "--g genofile --p phenofile " + "--model normal --method hk " + "--nperm 1000 --scale Mb " + "--control rs123456 " + "--addcovar --interval" + ) + }) -- cgit v1.2.3 From d8c4b1a0188574cdd70638a99e2984b54bec6033 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Jun 2021 22:16:26 +0000 Subject: Fixed test_rqtl.py to include Rscript in the command --- tests/unit/computations/test_rqtl.py | 82 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'tests/unit/computations/test_rqtl.py') diff --git a/tests/unit/computations/test_rqtl.py b/tests/unit/computations/test_rqtl.py index b16f136..3bf8f81 100644 --- a/tests/unit/computations/test_rqtl.py +++ b/tests/unit/computations/test_rqtl.py @@ -1,41 +1,41 @@ -"""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.json", - "rqtl_cmd": ( - "rqtl-wrapper " - "--g genofile --p phenofile " - "--model normal --method hk " - "--nperm 1000 --scale Mb " - "--control rs123456 " - "--addcovar --interval" - ) - }) +"""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.json", + "rqtl_cmd": ( + "Rscript rqtl-wrapper " + "--g genofile --p phenofile " + "--model normal --method hk " + "--nperm 1000 --scale Mb " + "--control rs123456 " + "--addcovar --interval" + ) + }) -- cgit v1.2.3 From 9dca7551ff6c1fa8c3b26ded2c1b63cfab001eca Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Jun 2021 22:21:46 +0000 Subject: Fixed file type from json to csv for test_generate_rqtl_command --- tests/unit/computations/test_rqtl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/unit/computations/test_rqtl.py') diff --git a/tests/unit/computations/test_rqtl.py b/tests/unit/computations/test_rqtl.py index 3bf8f81..09790b7 100644 --- a/tests/unit/computations/test_rqtl.py +++ b/tests/unit/computations/test_rqtl.py @@ -29,7 +29,7 @@ class TestRqtl(unittest.TestCase): "interval" ]), { "output_file": - "my-hash1my-hash2my-hash2-output.json", + "my-hash1my-hash2my-hash2-output.csv", "rqtl_cmd": ( "Rscript rqtl-wrapper " "--g genofile --p phenofile " -- cgit v1.2.3 From f7becfa11ca857104ecc1b668b4bd3d0a721083c Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 18 Jun 2021 22:28:37 +0000 Subject: Fixed another error where test_generate_rqtl_command didn't include the filename argument (not sure why running unit tests locally doesn't detect this) --- tests/unit/computations/test_rqtl.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/unit/computations/test_rqtl.py') diff --git a/tests/unit/computations/test_rqtl.py b/tests/unit/computations/test_rqtl.py index 09790b7..955d0ab 100644 --- a/tests/unit/computations/test_rqtl.py +++ b/tests/unit/computations/test_rqtl.py @@ -36,6 +36,7 @@ class TestRqtl(unittest.TestCase): "--model normal --method hk " "--nperm 1000 --scale Mb " "--control rs123456 " + "--filename my-hash1my-hash2my-hash2-output.csv " "--addcovar --interval" ) }) -- cgit v1.2.3