about summary refs log tree commit diff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-08-10 12:02:54 +0300
committerFrederick Muriuki Muriithi2022-08-12 13:13:26 +0300
commit3cc448e8ee95173dda7f2d50c0cf2ce743cd1926 (patch)
tree04c16587c51347bb19cbe65c3daaa7d7cc9573e2 /wqflask
parent361157f992af320abf73d93d9143b25017068184 (diff)
downloadgenenetwork2-3cc448e8ee95173dda7f2d50c0cf2ce743cd1926.tar.gz
Fix formatting for legibility
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/correlation/correlation_gn3_api.py23
-rw-r--r--wqflask/wqflask/correlation/rust_correlation.py39
2 files changed, 27 insertions, 35 deletions
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py
index e1e2613d..6df4eafe 100644
--- a/wqflask/wqflask/correlation/correlation_gn3_api.py
+++ b/wqflask/wqflask/correlation/correlation_gn3_api.py
@@ -224,19 +224,16 @@ def compute_correlation(start_vars, method="pearson", compute_all=False):
     correlation_results = correlation_results[0:corr_return_results]
 
     if (compute_all):
-        correlation_results = compute_corr_for_top_results(start_vars,
-                                                           correlation_results,
-                                                           this_trait,
-                                                           this_dataset,
-                                                           target_dataset,
-                                                           corr_type)
-
-    correlation_data = {"correlation_results": correlation_results,
-                        "this_trait": this_trait.name,
-                        "target_dataset": start_vars['corr_dataset'],
-                        "return_results": corr_return_results}
-
-    return correlation_data
+        correlation_results = compute_corr_for_top_results(
+            start_vars, correlation_results, this_trait, this_dataset,
+            target_dataset, corr_type)
+
+    return {
+        "correlation_results": correlation_results,
+        "this_trait": this_trait.name,
+        "target_dataset": start_vars['corr_dataset'],
+        "return_results": corr_return_results
+    }
 
 
 def compute_corr_for_top_results(start_vars,
diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py
index 8431f179..8a5021cc 100644
--- a/wqflask/wqflask/correlation/rust_correlation.py
+++ b/wqflask/wqflask/correlation/rust_correlation.py
@@ -33,8 +33,11 @@ def compute_top_n_tissue(this_dataset, this_trait, traits, method):
 
     # refactor lots of rpt
 
-    trait_symbol_dict = dict({trait_name: symbol for (
-        trait_name, symbol) in this_dataset.retrieve_genes("Symbol").items() if traits.get(trait_name)})
+    trait_symbol_dict = dict({
+        trait_name: symbol
+        for (trait_name, symbol)
+        in this_dataset.retrieve_genes("Symbol").items()
+        if traits.get(trait_name)})
 
     corr_result_tissue_vals_dict = get_trait_symbol_and_tissue_values(
         symbol_list=list(trait_symbol_dict.values()))
@@ -73,8 +76,9 @@ def merge_results(dict_a, dict_b, dict_c):
     return correlation_results
 
 
-def compute_correlation_rust(start_vars: dict, corr_type: str,
-                             method: str = "pearson", n_top: int = 500):
+def compute_correlation_rust(
+        start_vars: dict, corr_type: str, method: str = "pearson",
+        n_top: int = 500):
     """function to compute correlation"""
 
     (this_dataset, this_trait, target_dataset,
@@ -96,25 +100,15 @@ def compute_correlation_rust(start_vars: dict, corr_type: str,
             target_data.append(r)
 
 
-        results = run_correlation(target_data,
-                                  list(sample_data.values()),
-                                  method,
-                                  ",",
-                                  corr_type,
-                                  n_top)
+        results = run_correlation(
+            target_data, list(sample_data.values()), method, ",", corr_type,
+            n_top)
 
         # example compute of compute both correlation
-
-
-
         top_tissue_results = compute_top_n_tissue(this_dataset,this_trait,results,method)
-
-
         top_lit_results = compute_top_n_lit(results,this_dataset,this_trait)
 
-
         # merging the results
-
         results = merge_results(results,top_tissue_results,top_lit_results)
 
     if corr_type == "tissue":
@@ -134,8 +128,9 @@ def compute_correlation_rust(start_vars: dict, corr_type: str,
             results = run_correlation(
                 data[1], data[0], method, ",", "tissue")
 
-    return {"correlation_results": results,
-            "this_trait": this_trait.name,
-            "target_dataset": start_vars['corr_dataset'],
-            "return_results": n_top
-            }
+    return {
+        "correlation_results": results,
+        "this_trait": this_trait.name,
+        "target_dataset": start_vars['corr_dataset'],
+        "return_results": n_top
+    }