about summary refs log tree commit diff
path: root/gn3/db
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-10-29 08:25:13 +0300
committerBonfaceKilz2021-11-04 12:45:57 +0300
commit307a83b897b9ece7c9dd1af49bdedc9e1320eb61 (patch)
tree27a13596e854cdf151581e45bac81e639eaf0a4b /gn3/db
parent773c0896ccbed12170be2b5aed4554ab86d923b5 (diff)
downloadgenenetwork3-307a83b897b9ece7c9dd1af49bdedc9e1320eb61.tar.gz
Rework sorting: remove `compare_tissue_correlation_absolute_values`
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi

* gn3/db/correlations.py: Remove the
  `compare_tissue_correlation_absolute_values` function which is no longer
  needed.
Diffstat (limited to 'gn3/db')
-rw-r--r--gn3/db/correlations.py19
1 files changed, 1 insertions, 18 deletions
diff --git a/gn3/db/correlations.py b/gn3/db/correlations.py
index 28f050a..d7954e5 100644
--- a/gn3/db/correlations.py
+++ b/gn3/db/correlations.py
@@ -140,22 +140,6 @@ def fetch_literature_correlations(
         cursor.execute("DROP TEMPORARY TABLE %s", temp_table)
         return dict(results)
 
-def compare_tissue_correlation_absolute_values(val1, val2):
-    """
-    Comparison function for use when sorting tissue correlation values.
-
-    This is a partial migration of the
-    `web.webqtl.correlation.CorrelationPage.getTempTissueCorrTable` function in
-    GeneNetwork1."""
-    try:
-        if abs(val1) < abs(val2):
-            return 1
-        if abs(val1) == abs(val2):
-            return 0
-        return -1
-    except TypeError:
-        return 0
-
 def fetch_symbol_value_pair_dict(
         symbol_list: Tuple[str, ...], data_id_dict: dict,
         conn: Any) -> Dict[str, Tuple[float, ...]]:
@@ -302,8 +286,7 @@ def build_temporary_tissue_correlations_table(
         method)
 
     symbol_corr_list = sorted(
-        symbol_corr_dict.items(),
-        key=compare_tissue_correlation_absolute_values)
+        symbol_corr_dict.items(), key=lambda key_val: key_val[1])
 
     temp_table_name = f"TOPTISSUE{random_string(8)}"
     create_query = (