aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/tests/unit/wqflask/correlation/test_show_corr_results.py56
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py93
2 files changed, 0 insertions, 149 deletions
diff --git a/wqflask/tests/unit/wqflask/correlation/test_show_corr_results.py b/wqflask/tests/unit/wqflask/correlation/test_show_corr_results.py
index 33601990..e29b18ca 100644
--- a/wqflask/tests/unit/wqflask/correlation/test_show_corr_results.py
+++ b/wqflask/tests/unit/wqflask/correlation/test_show_corr_results.py
@@ -1,7 +1,6 @@
import unittest
from unittest import mock
from wqflask.correlation.show_corr_results import get_header_fields
-from wqflask.correlation.show_corr_results import generate_corr_json
class AttributeSetter:
@@ -41,58 +40,3 @@ class TestShowCorrResults(unittest.TestCase):
result2 = get_header_fields("Other", "Other")
self.assertEqual(result1, expected[0])
self.assertEqual(result2, expected[1])
-
- @mock.patch("wqflask.correlation.show_corr_results.hmac.data_hmac")
- def test_generate_corr_json(self, mock_data_hmac):
- mock_data_hmac.return_value = "hajsdiau"
-
- dataset = AttributeSetter({"name": "the_name"})
- this_trait = AttributeSetter(
- {"name": "trait_test", "dataset": dataset})
- target_dataset = AttributeSetter({"type": "Publish"})
- corr_trait_1 = AttributeSetter({
- "name": "trait_1",
- "dataset": AttributeSetter({"name": "dataset_1"}),
- "view": True,
- "abbreviation": "T1",
- "description_display": "Trait I description",
- "authors": "JM J,JYEW",
- "pubmed_id": "34n4nn31hn43",
- "pubmed_text": "2016",
- "pubmed_link": "https://www.load",
- "lod_score": "",
- "mean": "",
- "LRS_location_repr": "BXBS",
- "additive": "",
- "sample_r": 10.5,
- "num_overlap": 2,
- "sample_p": 5
-
-
-
-
- })
- corr_results = [corr_trait_1]
-
- dataset_type_other = {
- "location": "cx-3-4",
- "sample_4": 12.32,
- "num_overlap": 3,
- "sample_p": 10.34
- }
-
- expected_results = '[{"index": 1, "trait_id": "trait_1", "dataset": "dataset_1", "hmac": "hajsdiau", "abbreviation_display": "T1", "description": "Trait I description", "mean": "N/A", "authors_display": "JM J,JYEW", "additive": "N/A", "pubmed_id": "34n4nn31hn43", "year": "2016", "lod_score": "N/A", "lrs_location": "BXBS", "sample_r": "10.500", "num_overlap": 2, "sample_p": "5.000e+00"}]'
-
- results1 = generate_corr_json(corr_results=corr_results, this_trait=this_trait,
- dataset=dataset, target_dataset=target_dataset, for_api=True)
- self.assertEqual(expected_results, results1)
-
- def test_generate_corr_json_view_false(self):
- trait = AttributeSetter({"view": False})
- corr_results = [trait]
- this_trait = AttributeSetter({"name": "trait_test"})
- dataset = AttributeSetter({"name": "the_name"})
-
- results_where_view_is_false = generate_corr_json(
- corr_results=corr_results, this_trait=this_trait, dataset={}, target_dataset={}, for_api=False)
- self.assertEqual(results_where_view_is_false, "[]")
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index a1b45ff6..cda34bee 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -222,99 +222,6 @@ def correlation_json_for_table(start_vars, correlation_data, this_trait, this_da
return json.dumps(results_list)
-def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_api=False):
- results_list = []
- for i, trait in enumerate(corr_results):
- if trait.view == False:
- continue
- results_dict = {}
- results_dict['index'] = i + 1
- results_dict['trait_id'] = trait.name
- results_dict['dataset'] = trait.dataset.name
- results_dict['hmac'] = hmac.data_hmac(
- '{}:{}'.format(trait.name, trait.dataset.name))
- if target_dataset.type == "ProbeSet":
- results_dict['symbol'] = trait.symbol
- results_dict['description'] = "N/A"
- results_dict['location'] = trait.location_repr
- results_dict['mean'] = "N/A"
- results_dict['additive'] = "N/A"
- if bool(trait.description_display):
- results_dict['description'] = trait.description_display
- if bool(trait.mean):
- results_dict['mean'] = f"{float(trait.mean):.3f}"
- try:
- results_dict['lod_score'] = f"{float(trait.LRS_score_repr) / 4.61:.1f}"
- except:
- results_dict['lod_score'] = "N/A"
- results_dict['lrs_location'] = trait.LRS_location_repr
- if bool(trait.additive):
- results_dict['additive'] = f"{float(trait.additive):.3f}"
- results_dict['sample_r'] = f"{float(trait.sample_r):.3f}"
- results_dict['num_overlap'] = trait.num_overlap
- results_dict['sample_p'] = f"{float(trait.sample_p):.3e}"
- results_dict['lit_corr'] = "--"
- results_dict['tissue_corr'] = "--"
- results_dict['tissue_pvalue'] = "--"
- if bool(trait.lit_corr):
- results_dict['lit_corr'] = f"{float(trait.lit_corr):.3f}"
- if bool(trait.tissue_corr):
- results_dict['tissue_corr'] = f"{float(trait.tissue_corr):.3f}"
- results_dict['tissue_pvalue'] = f"{float(trait.tissue_pvalue):.3e}"
- elif target_dataset.type == "Publish":
- results_dict['abbreviation_display'] = "N/A"
- results_dict['description'] = "N/A"
- results_dict['mean'] = "N/A"
- results_dict['authors_display'] = "N/A"
- results_dict['additive'] = "N/A"
- if for_api:
- results_dict['pubmed_id'] = "N/A"
- results_dict['year'] = "N/A"
- else:
- results_dict['pubmed_link'] = "N/A"
- results_dict['pubmed_text'] = "N/A"
-
- if bool(trait.abbreviation):
- results_dict['abbreviation_display'] = trait.abbreviation
- if bool(trait.description_display):
- results_dict['description'] = trait.description_display
- if bool(trait.mean):
- results_dict['mean'] = f"{float(trait.mean):.3f}"
- if bool(trait.authors):
- authors_list = trait.authors.split(',')
- if len(authors_list) > 6:
- results_dict['authors_display'] = ", ".join(
- authors_list[:6]) + ", et al."
- else:
- results_dict['authors_display'] = trait.authors
- if bool(trait.pubmed_id):
- if for_api:
- results_dict['pubmed_id'] = trait.pubmed_id
- results_dict['year'] = trait.pubmed_text
- else:
- results_dict['pubmed_link'] = trait.pubmed_link
- results_dict['pubmed_text'] = trait.pubmed_text
- try:
- results_dict['lod_score'] = f"{float(trait.LRS_score_repr) / 4.61:.1f}"
- except:
- results_dict['lod_score'] = "N/A"
- results_dict['lrs_location'] = trait.LRS_location_repr
- if bool(trait.additive):
- results_dict['additive'] = f"{float(trait.additive):.3f}"
- results_dict['sample_r'] = f"{float(trait.sample_r):.3f}"
- results_dict['num_overlap'] = trait.num_overlap
- results_dict['sample_p'] = f"{float(trait.sample_p):.3e}"
- else:
- results_dict['location'] = trait.location_repr
- results_dict['sample_r'] = f"{float(trait.sample_r):.3f}"
- results_dict['num_overlap'] = trait.num_overlap
- results_dict['sample_p'] = f"{float(trait.sample_p):.3e}"
-
- results_list.append(results_dict)
-
- return json.dumps(results_list)
-
-
def get_formatted_corr_type(corr_type, corr_method):
formatted_corr_type = ""
if corr_type == "lit":