aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/test_gemma.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-04 23:05:34 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commit4cf5c29a06001577054b3548a24d895cf1911e13 (patch)
tree3912c611a7799cce56a860ce900d5d412b22ebea /tests/integration/test_gemma.py
parent747c9f5cb96d24f5f498127ec6cc89aa28ad50db (diff)
downloadgenenetwork3-4cf5c29a06001577054b3548a24d895cf1911e13.tar.gz
Add new endpoint
"/gwa-compute/<k_filename>/loco/covariates/maf/<maf>/<token>"
Diffstat (limited to 'tests/integration/test_gemma.py')
-rw-r--r--tests/integration/test_gemma.py49
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py
index 61421f2..6d2116b 100644
--- a/tests/integration/test_gemma.py
+++ b/tests/integration/test_gemma.py
@@ -324,7 +324,6 @@ class GemmaAPITest(unittest.TestCase):
"geno": "genofile.txt",
"pheno": "phenofile.txt",
"snps": "snpfile.txt",
- "covar": "covarfile.txt",
}
mock_hash.return_value = "hash"
response = self.app.post(("/api/gemma/gwa-compute/"
@@ -349,3 +348,51 @@ class GemmaAPITest(unittest.TestCase):
"status": "queued",
"output_file": "hash-gwa-output.json"
})
+
+ @mock.patch("gn3.api.gemma.queue_cmd")
+ @mock.patch("gn3.api.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,
+ mock_json, mock_hash,
+ mock_queue_cmd):
+ """Test /gemma/gwa-compute/<k-inputfile>/loco/covariates/maf/<maf><token>
+
+ """
+ mock_path_exist.return_value, _redis_conn = True, mock.MagicMock()
+ mock_redis.return_value = _redis_conn
+ mock_queue_cmd.return_value = "my-unique-id"
+ mock_json.return_value = {
+ "geno": "genofile.txt",
+ "pheno": "phenofile.txt",
+ "snps": "snpfile.txt",
+ "covar": "covarfile.txt",
+ }
+ mock_hash.return_value = "hash"
+ response = self.app.post(("/api/gemma/gwa-compute/"
+ "hash-k-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_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 -- "
+ "-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"
+ })