diff options
author | Alexanderlacuna | 2020-11-11 23:06:27 +0300 |
---|---|---|
committer | Alexanderlacuna | 2020-11-11 23:06:27 +0300 |
commit | 3396e1f008f3605439b38837f7a50407588d1f9b (patch) | |
tree | 3a25296868745c3e38a3f4ee8bba7fd928e2fb2c /wqflask/tests | |
parent | 424f44c0656da8f99dce0fa0a00bd5e6ba9bace3 (diff) | |
download | genenetwork2-3396e1f008f3605439b38837f7a50407588d1f9b.tar.gz |
add tests for marker_regression/run_mapping.py
Diffstat (limited to 'wqflask/tests')
-rw-r--r-- | wqflask/tests/wqflask/marker_regression/test_run_mapping.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py index 6521c41d..be6e6e48 100644 --- a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py @@ -7,6 +7,8 @@ from wqflask.marker_regression.run_mapping import geno_db_exists from wqflask.marker_regression.run_mapping import write_input_for_browser from wqflask.marker_regression.run_mapping import export_mapping_results from wqflask.marker_regression.run_mapping import trim_markers_for_figure +from wqflask.marker_regression.run_mapping import get_perm_strata +from wqflask.marker_regression.run_mapping import get_chr_lengths class AttributeSetter: @@ -23,10 +25,27 @@ class MockDataSetGroup(AttributeSetter): class TestRunMapping(unittest.TestCase): def setUp(self): + self.group = MockDataSetGroup( {"genofile": "~/genofiles/g1_file", "name": "GP1_", "species": "Human"}) + chromosomes={ + "3":AttributeSetter({ + "name":"C1", + "length":"0.04" + }), + "4":AttributeSetter({ + "name":"C2", + "length":"0.03" + }), + "5":AttributeSetter({ + "name":"C4", + "length":"0.01" + }) + } self.dataset = AttributeSetter( {"fullname": "dataser_1", "group": self.group, "type": "ProbeSet"}) + + self.chromosomes=AttributeSetter({"chromosomes":chromosomes}) self.trait = AttributeSetter( {"symbol": "IGFI", "chr": "X1", "mb": 123313}) @@ -196,3 +215,69 @@ class TestRunMapping(unittest.TestCase): results=write_input_for_browser(this_dataset=self.dataset,gwas_results={},annotations={}) self.assertEqual(results,expected) + + + def test_get_perm_strata(self): + categorical_vars=["C1","C2","W1"] + used_samples=["S1","S2"] + sample_list=AttributeSetter({"sample_attribute_values":{ + "S1":{ + "C1":"c1_value", + "C2":"c2_value", + "W1":"w1_value" + + }, + "S2":{ + "W1":"w2_value", + "W2":"w2_value" + + }, + "S3":{ + + "C1":"c1_value", + "C2":"c2_value" + + }, + + }}) + + results=get_perm_strata(this_trait={},sample_list=sample_list,categorical_vars=categorical_vars,used_samples=used_samples) + self.assertEqual(results,[2,1]) + + + def test_get_chr_length(self): + chromosomes=AttributeSetter({"chromosomes":self.chromosomes}) + dataset=AttributeSetter({"species":chromosomes}) + results=get_chr_lengths(mapping_scale="physic",mapping_method="reaper",dataset=dataset,qtl_results=[]) + chr_lengths=[] + for key,chromo in self.chromosomes.chromosomes.items(): + chr_lengths.append({"chr":chromo.name,"size":chromo.length}) + + self.assertEqual(chr_lengths,results) + + qtl_results=[{ + "chr":"16", + "cM":"0.2" + }, + { + "chr":"12", + "cM":"0.5" + }, + { + "chr":"18", + "cM":"0.1" + }, + { + "chr":"22", + "cM":"0.4" + }, + ] + + + + result_with_other_mapping_scale=get_chr_lengths(mapping_scale="other",mapping_method="reaper",dataset=dataset,qtl_results=qtl_results) + expected_value= [{'chr': '1', 'size': '0'}, {'chr': '16', 'size': '500000.0'}, {'chr': '18', 'size': '400000.0'}] + + self.assertEqual(result_with_other_mapping_scale,expected_value) + + |