about summary refs log tree commit diff
path: root/gn3/computations/partial_correlations.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-10-22 13:27:54 -0500
committerFrederick Muriuki Muriithi2025-10-22 13:27:54 -0500
commit05013c13710eccadb69746bf186eb672c2af69c4 (patch)
tree71a706fd30bf0d535a0fab737bb0e42a1667e60b /gn3/computations/partial_correlations.py
parent977efbb54da284fb3e8476f200206d00cb8e64cd (diff)
downloadgenenetwork3-05013c13710eccadb69746bf186eb672c2af69c4.tar.gz
Fetch configs from app setting and pass them down
Fix the code to avoid using global variables holding configuration
variables to avoid the failures caused by action-at-a-distance effects
due to change of a value elsewhere.

This way, all code consistently receives the same configuration values
passed on from callers.

We pass on the following configuration settings:
* TMPDIR
* SQL_URI
* TEXTDIR
Diffstat (limited to 'gn3/computations/partial_correlations.py')
-rw-r--r--gn3/computations/partial_correlations.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/gn3/computations/partial_correlations.py b/gn3/computations/partial_correlations.py
index 6eb6c2f..8674910 100644
--- a/gn3/computations/partial_correlations.py
+++ b/gn3/computations/partial_correlations.py
@@ -16,7 +16,6 @@ import pandas
 import pingouin
 from scipy.stats import pearsonr, spearmanr
 
-from gn3.settings import TEXTDIR
 from gn3.chancy import random_string
 from gn3.function_helpers import  compose
 from gn3.data_helpers import parse_csv_line
@@ -668,9 +667,14 @@ def check_for_common_errors(# pylint: disable=[R0914]
     return non_error_result
 
 def partial_correlations_with_target_db(# pylint: disable=[R0913, R0914, R0911 too-many-positional-arguments]
-        conn: Any, primary_trait_name: str,
-        control_trait_names: Tuple[str, ...], method: str,
-        criteria: int, target_db_name: str) -> dict:
+        conn: Any,
+        primary_trait_name: str,
+        control_trait_names: Tuple[str, ...],
+        method: str,
+        criteria: int,
+        target_db_name: str,
+        textdir: str
+) -> dict:
     """
     This is the 'ochestration' function for the partial-correlation feature.
 
@@ -755,7 +759,7 @@ def partial_correlations_with_target_db(# pylint: disable=[R0913, R0914, R0911 t
         threshold,
         conn)
 
-    database_filename = get_filename(conn, target_db_name, TEXTDIR)
+    database_filename = get_filename(conn, target_db_name, textdir)
     all_correlations = partial_corrs(
         conn, check_res["common_primary_control_samples"],
         check_res["fixed_primary_values"], check_res["fixed_control_values"],