From 307a83b897b9ece7c9dd1af49bdedc9e1320eb61 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 29 Oct 2021 08:25:13 +0300 Subject: 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. --- gn3/db/correlations.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'gn3/db/correlations.py') 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 = ( -- cgit v1.2.3