diff options
author | Alexanderlacuna | 2020-11-12 21:11:28 +0300 |
---|---|---|
committer | Alexanderlacuna | 2020-11-12 21:11:28 +0300 |
commit | a48e8d5e652551eb2d57953304ea0ec3587217ce (patch) | |
tree | 249423498e13fe2866ab3529cb92a452f67f61fd /wqflask | |
parent | f4dbdc51102d942079c7159ac48071282ec995ea (diff) | |
download | genenetwork2-a48e8d5e652551eb2d57953304ea0ec3587217ce.tar.gz |
add test for parse gemma output in marker_regression/gemma_mapping.py
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py index e47c8335..bcc5dab9 100644 --- a/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py @@ -167,11 +167,29 @@ X\tgn7\t2324424\tQ\tE\tA\tP\tMMB\tCDE\t0.4 @mock.patch("wqflask.marker_regression.gemma_mapping.TEMPDIR", "/home/tmp") @mock.patch("wqflask.marker_regression.gemma_mapping.os") - def test_parse_loco_output_file_found(self, mock_os): + @mock.patch("wqflask.marker_regression.gemma_mapping.json") + def test_parse_loco_output_file_found(self,mock_json,mock_os): """add tests for parse loco output file found""" + mock_json.load.return_value={ + "files":[["file_name","user","~/file1"], + ["file_name","user","~/file2"]] + } + return_file_1="""X/Y\t L1\t21\tQ\tE\tA\tP\tMMB\tCDE\t0.5 +X/Y\tL2\t21322\tQ\tE\tA\tP\tMMB\tCDE\t0.5 +chr\tL3\t12312\tQ\tE\tA\tP\tMMB\tCDE\t0.7""" + return_file_2="""chr\tother\t21322\tQ\tE\tA\tP\tMMB\tCDE\t0.5""" mock_os.path.isfile.return_value = True file_to_write = """{"files":["file_1","file_2"]}""" - pass + with mock.patch("builtins.open") as mock_open: + + handles=(mock.mock_open(read_data="gwas").return_value,mock.mock_open(read_data=return_file_1).return_value,mock.mock_open(read_data=return_file_2).return_value) + mock_open.side_effect=handles + results = parse_loco_output( + this_dataset={}, gwa_output_filename=".xw/") + expected_results= [{'name': ' L1', 'chr': 'X/Y', 'Mb': 2.1e-05, 'p_value': 0.5, 'lod_score': 0.3010299956639812}, {'name': 'L2', 'chr': 'X/Y', 'Mb': 0.021322, 'p_value': 0.5, 'lod_score': 0.3010299956639812}] + + self.assertEqual(expected_results,results) + @mock.patch("wqflask.marker_regression.gemma_mapping.TEMPDIR", "/home/tmp") @mock.patch("wqflask.marker_regression.gemma_mapping.os") |