aboutsummaryrefslogtreecommitdiff
path: root/gn2/tests/unit/wqflask/correlation
diff options
context:
space:
mode:
authorArun Isaac2023-12-29 18:55:37 +0000
committerArun Isaac2023-12-29 19:01:46 +0000
commit204a308be0f741726b9a620d88fbc22b22124c81 (patch)
treeb3cf66906674020b530c844c2bb4982c8a0e2d39 /gn2/tests/unit/wqflask/correlation
parent83062c75442160427b50420161bfcae2c5c34c84 (diff)
downloadgenenetwork2-204a308be0f741726b9a620d88fbc22b22124c81.tar.gz
Namespace all modules under gn2.
We move all modules under a gn2 directory. This is important for "correct" packaging and deployment as a Guix service.
Diffstat (limited to 'gn2/tests/unit/wqflask/correlation')
-rw-r--r--gn2/tests/unit/wqflask/correlation/__init__.py0
-rw-r--r--gn2/tests/unit/wqflask/correlation/test_correlation_functions.py21
-rw-r--r--gn2/tests/unit/wqflask/correlation/test_correlation_gn3.py14
-rw-r--r--gn2/tests/unit/wqflask/correlation/test_show_corr_results.py42
4 files changed, 77 insertions, 0 deletions
diff --git a/gn2/tests/unit/wqflask/correlation/__init__.py b/gn2/tests/unit/wqflask/correlation/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/gn2/tests/unit/wqflask/correlation/__init__.py
diff --git a/gn2/tests/unit/wqflask/correlation/test_correlation_functions.py b/gn2/tests/unit/wqflask/correlation/test_correlation_functions.py
new file mode 100644
index 00000000..c0f57141
--- /dev/null
+++ b/gn2/tests/unit/wqflask/correlation/test_correlation_functions.py
@@ -0,0 +1,21 @@
+"""module contains tests for correlation functions"""
+
+import unittest
+from unittest import mock
+
+from gn2.wqflask.correlation.correlation_functions import get_trait_symbol_and_tissue_values
+from gn2.wqflask.correlation.correlation_functions import cal_zero_order_corr_for_tiss
+
+
+def test_tissue_corr_computation(mocker):
+ """Test for cal_zero_order_corr_for_tiss"""
+ primary_values = [9.288, 9.313, 8.988, 9.660, 8.21]
+ target_values = [9.586, 8.498, 9.362, 8.820, 8.786]
+ _m = mocker.patch(("wqflask.correlation.correlation_functions."
+ "compute_corr_coeff_p_value"),
+ return_value=(0.51, 0.7))
+ results = cal_zero_order_corr_for_tiss(primary_values, target_values)
+ _m.assert_called_once_with(
+ primary_values=primary_values, target_values=target_values,
+ corr_method="pearson")
+ assert len(results) == 3
diff --git a/gn2/tests/unit/wqflask/correlation/test_correlation_gn3.py b/gn2/tests/unit/wqflask/correlation/test_correlation_gn3.py
new file mode 100644
index 00000000..432dbc95
--- /dev/null
+++ b/gn2/tests/unit/wqflask/correlation/test_correlation_gn3.py
@@ -0,0 +1,14 @@
+"""this module contains tests for code used in integrating to gn3 api"""
+from unittest import TestCase
+from gn2.base.data_set import create_dataset
+
+class TestCorrelation(TestCase):
+
+ def test_create_dataset(self):
+ """test for creating datasets"""
+
+ pass
+ def test_fetch_dataset_info(self):
+ """test for fetching dataset info data"""
+
+ pass
diff --git a/gn2/tests/unit/wqflask/correlation/test_show_corr_results.py b/gn2/tests/unit/wqflask/correlation/test_show_corr_results.py
new file mode 100644
index 00000000..b1459dd9
--- /dev/null
+++ b/gn2/tests/unit/wqflask/correlation/test_show_corr_results.py
@@ -0,0 +1,42 @@
+import unittest
+from unittest import mock
+from gn2.wqflask.correlation.show_corr_results import get_header_fields
+
+
+class AttributeSetter:
+ def __init__(self, trait_obj):
+ for key, value in trait_obj.items():
+ setattr(self, key, value)
+
+
+class TestShowCorrResults(unittest.TestCase):
+ def test_get_header_fields(self):
+ expected = [
+ ['Index',
+ 'Record',
+ 'Symbol',
+ 'Description',
+ 'Location',
+ 'Mean',
+ 'Sample rho',
+ 'N',
+ 'Sample p(rho)',
+ 'Lit rho',
+ 'Tissue rho',
+ 'Tissue p(rho)',
+ 'Max LRS',
+ 'Max LRS Location',
+ 'Additive Effect'],
+
+ ['Index',
+ 'ID',
+ 'Location',
+ 'Sample r',
+ 'N',
+ 'Sample p(r)']
+
+ ]
+ result1 = get_header_fields("ProbeSet", "spearman")
+ result2 = get_header_fields("Other", "Other")
+ self.assertEqual(result1, expected[0])
+ self.assertEqual(result2, expected[1])