From 776598729bcff12bea933ff7cb4864e1c3eea0c8 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Mar 2021 15:26:33 +0300 Subject: Delete "generate_gemma_computation_cmd" --- gn3/computations/gemma.py | 22 ---------------------- tests/unit/computations/test_gemma.py | 21 --------------------- 2 files changed, 43 deletions(-) diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py index 3c6bd29..bf8b151 100644 --- a/gn3/computations/gemma.py +++ b/gn3/computations/gemma.py @@ -49,28 +49,6 @@ def do_paths_exist(paths: ValuesView) -> bool: return True -def generate_gemma_computation_cmd( - gemma_cmd: str, gemma_kwargs: Dict[str, str], output_file: str, - gemma_wrapper_kwargs: Dict[str, str]) -> Optional[str]: - """Create a computation cmd""" - geno_filename = gemma_kwargs.get("geno_filename", "") - trait_filename = gemma_kwargs.get("trait_filename") - ext, snps_filename = geno_filename.partition(".")[-1], "" - if geno_filename: - snps_filename = geno_filename.replace(f".{ext}", "") - snps_filename += f"_snps.{ext}" - _kwargs = {"g": geno_filename, "p": trait_filename} - _kwargs["a"] = snps_filename - if not do_paths_exist(_kwargs.values()): # Prevents injection! - return None - if _kwargs.get("lmm"): - _kwargs["lmm"] = gemma_kwargs.get("lmm") - return compose_gemma_cmd(gemma_wrapper_cmd=gemma_cmd, - gemma_wrapper_kwargs=gemma_wrapper_kwargs, - gemma_kwargs=_kwargs, - gemma_args=["-gk", ">", output_file]) - - # pylint: disable=R0913 def generate_gemma_cmd(gemma_cmd: str, output_dir: str, diff --git a/tests/unit/computations/test_gemma.py b/tests/unit/computations/test_gemma.py index 4a76bef..f3b31e5 100644 --- a/tests/unit/computations/test_gemma.py +++ b/tests/unit/computations/test_gemma.py @@ -5,7 +5,6 @@ from unittest import mock from gn3.computations.gemma import generate_gemma_cmd from gn3.computations.gemma import generate_hash_of_string from gn3.computations.gemma import generate_pheno_txt_file -from gn3.computations.gemma import generate_gemma_computation_cmd class TestGemma(unittest.TestCase): @@ -32,26 +31,6 @@ class TestGemma(unittest.TestCase): self.assertEqual(generate_hash_of_string("I^iQP&TlSR^z"), "hMVRw8kbEp49rOmoIkhMjA") - @mock.patch("gn3.computations.gemma.do_paths_exist") - def test_compose_k_computation_cmd(self, mock_pathsp): - """Test that a K computation cmd is constructed properly""" - mock_pathsp.return_value = True - self.assertEqual( - generate_gemma_computation_cmd( - gemma_cmd="gemma-wrapper", - gemma_wrapper_kwargs=None, - gemma_kwargs={ - "geno_filename": "genofile.txt", - "trait_filename": "test.txt", - "covar_filename": "genofile_snps.txt" - }, - output_file="/tmp/gn2/k_output_gUFhGu4rLG7k+CXLPk1OUg.txt", - ), ("gemma-wrapper --json -- " - "-g genofile.txt -p " - "test.txt -a genofile_snps.txt " - "-gk > /tmp/gn2/" - "k_output_gUFhGu4rLG7k+CXLPk1OUg.txt")) - @mock.patch("gn3.computations.gemma.get_hash_of_files") def test_compute_k_values_without_loco(self, mock_get_hash): """Test computing k valuse without loco""" -- cgit v1.2.3