aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-10-19 10:31:24 +0300
committerFrederick Muriuki Muriithi2021-10-19 10:31:24 +0300
commitefb9896464f969de4fe8fcaee21a19ac1d881fa2 (patch)
tree71704f2bc0396744ba25f90c5ccbb6eacb3c08c8 /tests/unit
parent3304fa682924b8f6bff5126ecf2fb58f4201b968 (diff)
downloadgenenetwork3-efb9896464f969de4fe8fcaee21a19ac1d881fa2.tar.gz
Implement remaining `fix_samples` functionality
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * gn3/partial_correlations.py: implement `fix_samples` function * tests/unit/test_partial_correlations.py: implement tests for `fix_samples` function Implement the remaining partial migration for the `web.webqtl.correlation.correlationFunction.fixStrain` function in GN1.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_partial_correlations.py52
1 files changed, 38 insertions, 14 deletions
diff --git a/tests/unit/test_partial_correlations.py b/tests/unit/test_partial_correlations.py
index 6302f74..7631a71 100644
--- a/tests/unit/test_partial_correlations.py
+++ b/tests/unit/test_partial_correlations.py
@@ -1,7 +1,10 @@
"""Module contains tests for gn3.partial_correlations"""
from unittest import TestCase
-from gn3.partial_correlations import control_samples, dictify_by_samples
+from gn3.partial_correlations import (
+ fix_samples,
+ control_samples,
+ dictify_by_samples)
sampleslist = ["B6cC3-1", "BXD1", "BXD12", "BXD16", "BXD19", "BXD2"]
control_traits = (
@@ -69,6 +72,21 @@ control_traits = (
"sample_name": "BXD2", "value": 7.80944, "variance": None,
"ndata": None}}})
+dictified_control_samples = (
+ {"B6cC3-1": {"sample_name": "B6cC3-1", "value": 7.51879, "variance": None},
+ "BXD1": {"sample_name": "BXD1", "value": 7.77141, "variance": None},
+ "BXD12": {"sample_name": "BXD12", "value": 8.39265, "variance": None},
+ "BXD16": {"sample_name": "BXD16", "value": 8.17443, "variance": None},
+ "BXD19": {"sample_name": "BXD19", "value": 8.30401, "variance": None},
+ "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}},
+ {"BXD12": {"sample_name": "BXD12", "value": 8.39265, "variance": None},
+ "BXD16": {"sample_name": "BXD16", "value": 8.17443, "variance": None},
+ "BXD19": {"sample_name": "BXD19", "value": 8.30401, "variance": None},
+ "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}},
+ {"B6cC3-1": {"sample_name": "B6cC3-1", "value": 7.51879, "variance": None},
+ "BXD1": {"sample_name": "BXD1", "value": 7.77141, "variance": None},
+ "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}})
+
class TestPartialCorrelations(TestCase):
"""Class for testing partial correlations computation functions"""
@@ -112,16 +130,22 @@ class TestPartialCorrelations(TestCase):
((None, None, None, None, None, None), (None, None, None, None),
(None, None, None)),
(6, 4, 3))),
- ({"B6cC3-1": {"sample_name": "B6cC3-1", "value": 7.51879, "variance": None},
- "BXD1": {"sample_name": "BXD1", "value": 7.77141, "variance": None},
- "BXD12": {"sample_name": "BXD12", "value": 8.39265, "variance": None},
- "BXD16": {"sample_name": "BXD16", "value": 8.17443, "variance": None},
- "BXD19": {"sample_name": "BXD19", "value": 8.30401, "variance": None},
- "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}},
- {"BXD12": {"sample_name": "BXD12", "value": 8.39265, "variance": None},
- "BXD16": {"sample_name": "BXD16", "value": 8.17443, "variance": None},
- "BXD19": {"sample_name": "BXD19", "value": 8.30401, "variance": None},
- "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}},
- {"B6cC3-1": {"sample_name": "B6cC3-1", "value": 7.51879, "variance": None},
- "BXD1": {"sample_name": "BXD1", "value": 7.77141, "variance": None},
- "BXD2": {"sample_name": "BXD2", "value": 7.80944, "variance": None}}))
+ dictified_control_samples)
+
+ def test_fix_samples(self):
+ """Test that fix_samples fixes the values"""
+ self.assertEqual(
+ fix_samples(
+ {"B6cC3-1": {"sample_name": "B6cC3-1", "value": 7.51879,
+ "variance": None},
+ "BXD1": {"sample_name": "BXD1", "value": 7.77141,
+ "variance": None},
+ "BXD2": {"sample_name": "BXD2", "value": 7.80944,
+ "variance": None}},
+ dictified_control_samples),
+ (("BXD2",), (7.80944,),
+ (7.51879, 7.77141, 8.39265, 8.17443, 8.30401, 7.80944, 8.39265,
+ 8.17443, 8.30401, 7.80944, 7.51879, 7.77141, 7.80944),
+ (None,),
+ (None, None, None, None, None, None, None, None, None, None, None,
+ None, None)))