about summary refs log tree commit diff
path: root/tests/integration/test_gemma.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-05 16:00:25 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commit529e72eb1aed89e018428cabdf63e98983c508ed (patch)
tree4a278473a75e2c1c95e8478aedaa79643a51f5d2 /tests/integration/test_gemma.py
parenta896c25bbe4f640665d547307efe389817f17848 (diff)
downloadgenenetwork3-529e72eb1aed89e018428cabdf63e98983c508ed.tar.gz
Replace "compute_k_values" with "generate_gemma_cmd"
Diffstat (limited to 'tests/integration/test_gemma.py')
-rw-r--r--tests/integration/test_gemma.py150
1 files changed, 75 insertions, 75 deletions
diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py
index f4ac685..4573de1 100644
--- a/tests/integration/test_gemma.py
+++ b/tests/integration/test_gemma.py
@@ -187,21 +187,21 @@ class GemmaAPITest(unittest.TestCase):
                  "-g /tmp/test-data/genofile.txt "
                  "-p /tmp/test-data/phenofile.txt "
                  "-a /tmp/test-data/snpfile.txt "
-                 "-gk > /tmp/test-data/hash-k-output.json"))
-        self.assertEqual(response.get_json(), {
-            "output_file": "hash-k-output.json",
-            "status": "queued",
-            "unique_id": "my-unique-id"
-        })
+                 "-gk > /tmp/test-data/hash-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "output_file": "hash-output.json",
+                "status": "queued",
+                "unique_id": "my-unique-id"
+            })
 
     @mock.patch("gn3.api.gemma.queue_cmd")
     @mock.patch("gn3.computations.gemma.get_hash_of_files")
     @mock.patch("gn3.api.gemma.jsonfile_to_dict")
     @mock.patch("gn3.api.gemma.do_paths_exist")
     @mock.patch("gn3.api.gemma.redis.Redis")
-    def test_k_compute_loco(self, mock_redis, mock_path_exist,
-                            mock_json, mock_hash,
-                            mock_queue_cmd):
+    def test_k_compute_loco(self, mock_redis, mock_path_exist, mock_json,
+                            mock_hash, mock_queue_cmd):
         """Test /gemma/k-compute/loco/<chromosomes>/<token>"""
         mock_path_exist.return_value, _redis_conn = True, mock.MagicMock()
         mock_redis.return_value = _redis_conn
@@ -223,21 +223,21 @@ class GemmaAPITest(unittest.TestCase):
                  "-g /tmp/test-data/genofile.txt "
                  "-p /tmp/test-data/phenofile.txt "
                  "-a /tmp/test-data/snpfile.txt "
-                 "-gk > /tmp/test-data/hash-3R77Mz-k-output.json"))
-        self.assertEqual(response.get_json(), {
-            "output_file": "hash-3R77Mz-k-output.json",
-            "status": "queued",
-            "unique_id": "my-unique-id"
-        })
+                 "-gk > /tmp/test-data/hash-3R77Mz-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "output_file": "hash-3R77Mz-output.json",
+                "status": "queued",
+                "unique_id": "my-unique-id"
+            })
 
     @mock.patch("gn3.api.gemma.queue_cmd")
-    @mock.patch("gn3.api.gemma.get_hash_of_files")
+    @mock.patch("gn3.computations.gemma.get_hash_of_files")
     @mock.patch("gn3.api.gemma.jsonfile_to_dict")
     @mock.patch("gn3.api.gemma.do_paths_exist")
     @mock.patch("gn3.api.gemma.redis.Redis")
-    def test_gwa_compute(self, mock_redis, mock_path_exist,
-                         mock_json, mock_hash,
-                         mock_queue_cmd):
+    def test_gwa_compute(self, mock_redis, mock_path_exist, mock_json,
+                         mock_hash, mock_queue_cmd):
         """Test /gemma/gwa-compute/<k-inputfile>/<token>"""
         mock_path_exist.return_value, _redis_conn = True, mock.MagicMock()
         mock_redis.return_value = _redis_conn
@@ -250,9 +250,10 @@ class GemmaAPITest(unittest.TestCase):
         mock_hash.return_value = "hash"
         response = self.app.post(("/api/gemma/gwa-compute/hash-k-output.json/"
                                   "my-token"))
-        mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt',
-                                           '/tmp/my-token/phenofile.txt',
-                                           '/tmp/my-token/snpfile.txt'])
+        mock_hash.assert_called_once_with([
+            '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+            '/tmp/my-token/snpfile.txt'
+        ])
         mock_queue_cmd.assert_called_once_with(
             conn=_redis_conn,
             email=None,
@@ -262,22 +263,21 @@ class GemmaAPITest(unittest.TestCase):
                  " -- -g /tmp/my-token/genofile.txt "
                  "-p /tmp/my-token/phenofile.txt "
                  "-a /tmp/my-token/snpfile.txt "
-                 "-lmm 9 gk > /tmp/my-token/hash-gwa-output.json"))
-        self.assertEqual(response.get_json(), {
-            "unique_id": "my-unique-id",
-            "status": "queued",
-            "output_file": "hash-gwa-output.json"
-        })
+                 "-lmm 9 -gk > /tmp/my-token/hash-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "unique_id": "my-unique-id",
+                "status": "queued",
+                "output_file": "hash-output.json"
+            })
 
     @mock.patch("gn3.api.gemma.queue_cmd")
-    @mock.patch("gn3.api.gemma.get_hash_of_files")
+    @mock.patch("gn3.computations.gemma.get_hash_of_files")
     @mock.patch("gn3.api.gemma.jsonfile_to_dict")
     @mock.patch("gn3.api.gemma.do_paths_exist")
     @mock.patch("gn3.api.gemma.redis.Redis")
-    def test_gwa_compute_with_covars(self, mock_redis,
-                                     mock_path_exist,
-                                     mock_json, mock_hash,
-                                     mock_queue_cmd):
+    def test_gwa_compute_with_covars(self, mock_redis, mock_path_exist,
+                                     mock_json, mock_hash, mock_queue_cmd):
         """Test /gemma/gwa-compute/covars/<k-inputfile>/<token>"""
         mock_path_exist.return_value, _redis_conn = True, mock.MagicMock()
         mock_redis.return_value = _redis_conn
@@ -293,10 +293,10 @@ class GemmaAPITest(unittest.TestCase):
         response = self.app.post(("/api/gemma/gwa-compute/"
                                   "covars/hash-k-output.json/"
                                   "my-token"))
-        mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt',
-                                           '/tmp/my-token/phenofile.txt',
-                                           '/tmp/my-token/snpfile.txt',
-                                           '/tmp/my-token/covarfile.txt'])
+        mock_hash.assert_called_once_with([
+            '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+            '/tmp/my-token/snpfile.txt', '/tmp/my-token/covarfile.txt'
+        ])
         mock_queue_cmd.assert_called_once_with(
             conn=_redis_conn,
             email=None,
@@ -307,22 +307,21 @@ class GemmaAPITest(unittest.TestCase):
                  "-p /tmp/my-token/phenofile.txt "
                  "-a /tmp/my-token/snpfile.txt "
                  "-c /tmp/my-token/covarfile.txt -lmm 9 "
-                 "-gk > /tmp/my-token/hash-gwa-output.json"))
-        self.assertEqual(response.get_json(), {
-            "unique_id": "my-unique-id",
-            "status": "queued",
-            "output_file": "hash-gwa-output.json"
-        })
+                 "-gk > /tmp/my-token/hash-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "unique_id": "my-unique-id",
+                "status": "queued",
+                "output_file": "hash-output.json"
+            })
 
     @mock.patch("gn3.api.gemma.queue_cmd")
-    @mock.patch("gn3.api.gemma.get_hash_of_files")
+    @mock.patch("gn3.computations.gemma.get_hash_of_files")
     @mock.patch("gn3.api.gemma.jsonfile_to_dict")
     @mock.patch("gn3.api.gemma.do_paths_exist")
     @mock.patch("gn3.api.gemma.redis.Redis")
-    def test_gwa_compute_with_loco_only(self, mock_redis,
-                                        mock_path_exist,
-                                        mock_json, mock_hash,
-                                        mock_queue_cmd):
+    def test_gwa_compute_with_loco_only(self, mock_redis, mock_path_exist,
+                                        mock_json, mock_hash, mock_queue_cmd):
         """Test /gemma/gwa-compute/<k-inputfile>/loco/maf/<maf>/<token>
 
         """
@@ -336,35 +335,36 @@ class GemmaAPITest(unittest.TestCase):
         }
         mock_hash.return_value = "hash"
         response = self.app.post(("/api/gemma/gwa-compute/"
-                                  "hash-k-output.json/loco/"
+                                  "hash-output.json/loco/"
                                   "maf/21/my-token"))
-        mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt',
-                                           '/tmp/my-token/phenofile.txt',
-                                           '/tmp/my-token/snpfile.txt'])
+        mock_hash.assert_called_once_with([
+            '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+            '/tmp/my-token/snpfile.txt'
+        ])
         mock_queue_cmd.assert_called_once_with(
             conn=_redis_conn,
             email=None,
             job_queue='GN3::job-queue',
             cmd=("gemma-wrapper --json --loco --input "
-                 "/tmp/my-token/hash-k-output.json -- "
+                 "/tmp/my-token/hash-output.json -- "
                  "-g /tmp/my-token/genofile.txt "
                  "-p /tmp/my-token/phenofile.txt "
                  "-a /tmp/my-token/snpfile.txt "
                  "-lmm 9 -maf 21.0 "
-                 "-gk > /tmp/my-token/hash-gwa-output.json"))
-        self.assertEqual(response.get_json(), {
-            "unique_id": "my-unique-id",
-            "status": "queued",
-            "output_file": "hash-gwa-output.json"
-        })
+                 "-gk > /tmp/my-token/hash-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "unique_id": "my-unique-id",
+                "status": "queued",
+                "output_file": "hash-output.json"
+            })
 
     @mock.patch("gn3.api.gemma.queue_cmd")
-    @mock.patch("gn3.api.gemma.get_hash_of_files")
+    @mock.patch("gn3.computations.gemma.get_hash_of_files")
     @mock.patch("gn3.api.gemma.jsonfile_to_dict")
     @mock.patch("gn3.api.gemma.do_paths_exist")
     @mock.patch("gn3.api.gemma.redis.Redis")
-    def test_gwa_compute_with_loco_covars(self, mock_redis,
-                                          mock_path_exist,
+    def test_gwa_compute_with_loco_covars(self, mock_redis, mock_path_exist,
                                           mock_json, mock_hash,
                                           mock_queue_cmd):
         """Test /gemma/gwa-compute/<k-inputfile>/loco/covariates/maf/<maf><token>
@@ -381,27 +381,27 @@ class GemmaAPITest(unittest.TestCase):
         }
         mock_hash.return_value = "hash"
         response = self.app.post(("/api/gemma/gwa-compute/"
-                                  "hash-k-output.json/loco/"
+                                  "hash-output.json/loco/"
                                   "covariates/maf/21/my-token"))
-        mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt',
-                                           '/tmp/my-token/phenofile.txt',
-                                           '/tmp/my-token/snpfile.txt',
-                                           "/tmp/my-token/covarfile.txt"
-                                           ])
+        mock_hash.assert_called_once_with([
+            '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+            '/tmp/my-token/snpfile.txt', "/tmp/my-token/covarfile.txt"
+        ])
         mock_queue_cmd.assert_called_once_with(
             conn=_redis_conn,
             email=None,
             job_queue='GN3::job-queue',
             cmd=("gemma-wrapper --json --loco --input "
-                 "/tmp/my-token/hash-k-output.json -- "
+                 "/tmp/my-token/hash-output.json -- "
                  "-g /tmp/my-token/genofile.txt "
                  "-p /tmp/my-token/phenofile.txt "
                  "-a /tmp/my-token/snpfile.txt "
                  "-c /tmp/my-token/covarfile.txt "
                  "-lmm 9 -maf 21.0 "
-                 "-gk > /tmp/my-token/hash-gwa-output.json"))
-        self.assertEqual(response.get_json(), {
-            "unique_id": "my-unique-id",
-            "status": "queued",
-            "output_file": "hash-gwa-output.json"
-        })
+                 "-gk > /tmp/my-token/hash-output.json"))
+        self.assertEqual(
+            response.get_json(), {
+                "unique_id": "my-unique-id",
+                "status": "queued",
+                "output_file": "hash-output.json"
+            })