aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/computations/test_heatmap.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-08-20 14:10:45 +0300
committerMuriithi Frederick Muriuki2021-08-20 14:10:45 +0300
commit8b2c776771d2a70613a1e31d6e6671b612cfbafc (patch)
treead7ab6dcd4c43b15afdbe74322fbac76db0f34db /tests/unit/computations/test_heatmap.py
parentded960e3d32e4d7ebe590deda27fc47175be73d9 (diff)
downloadgenenetwork3-8b2c776771d2a70613a1e31d6e6671b612cfbafc.tar.gz
Retrieve the strains with valid values
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/heatmap.py: add function to get strains with values * tests/unit/computations/test_heatmap.py: new tests Add function to get the strains whose values are not `None` from the `trait_data` object passed in. This migrates https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/Heatmap.py#L215-221 into a separate function that can handle that and be tested independently of any other code.
Diffstat (limited to 'tests/unit/computations/test_heatmap.py')
-rw-r--r--tests/unit/computations/test_heatmap.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/unit/computations/test_heatmap.py b/tests/unit/computations/test_heatmap.py
index 14807bb..686288d 100644
--- a/tests/unit/computations/test_heatmap.py
+++ b/tests/unit/computations/test_heatmap.py
@@ -3,7 +3,8 @@ from unittest import TestCase
from gn3.computations.heatmap import (
cluster_traits,
export_trait_data,
- compute_heatmap_order)
+ compute_heatmap_order,
+ retrieve_strains_and_values)
strainlist = ["B6cC3-1", "BXD1", "BXD12", "BXD16", "BXD19", "BXD2"]
trait_data = {
@@ -164,3 +165,14 @@ class TestHeatmap(TestCase):
with self.subTest(xoffset=xoff):
self.assertEqual(
compute_heatmap_order(slinked, xoffset=xoff), expected)
+
+ def test_retrieve_strains_and_values(self):
+ """Test retrieval of strains and values."""
+ for slist, tdata, expected in [
+ [["s1", "s2", "s3", "s4"], [9, None, 5, 4],
+ (("s1", "s3", "s4"), (9, 5, 4))],
+ [["s1", "s2", "s3", "s4", "s5"], [6, None, None, 4, None],
+ (("s1", "s4"), (6, 4))]]:
+ with self.subTest(strainlist=slist, traitdata=tdata):
+ self.assertEqual(
+ retrieve_strains_and_values(slist, tdata), expected)