diff options
-rw-r--r-- | wqflask/wqflask/correlation/correlation_gn3_api.py | 4 | ||||
-rw-r--r-- | wqflask/wqflask/correlation/rust_correlation.py | 17 |
2 files changed, 10 insertions, 11 deletions
diff --git a/wqflask/wqflask/correlation/correlation_gn3_api.py b/wqflask/wqflask/correlation/correlation_gn3_api.py index b09f3ae2..cffcda60 100644 --- a/wqflask/wqflask/correlation/correlation_gn3_api.py +++ b/wqflask/wqflask/correlation/correlation_gn3_api.py @@ -3,7 +3,7 @@ import json import time from functools import wraps -from flask import current_app +from utility.tools import SQL_URI from wqflask.correlation import correlation_functions from wqflask.correlation.pre_computes import fetch_precompute_results @@ -148,7 +148,7 @@ def lit_for_trait_list(corr_results, this_dataset, this_trait): geneid_dict = {trait_name: geneid for (trait_name, geneid) in geneid_dict.items() if trait_lists.get(trait_name)} - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: correlation_results = compute_all_lit_correlation( conn=conn, trait_lists=list(geneid_dict.items()), species=species, gene_id=this_trait_geneid) diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py index cfec1ae3..67bd5ff5 100644 --- a/wqflask/wqflask/correlation/rust_correlation.py +++ b/wqflask/wqflask/correlation/rust_correlation.py @@ -2,8 +2,7 @@ import json from functools import reduce -from flask import current_app - +from utility.tools import SQL_URI from utility.db_tools import mescape from utility.db_tools import create_in_clause from wqflask.correlation.correlation_functions\ @@ -29,7 +28,7 @@ def query_probes_metadata(dataset, trait_list): if not bool(trait_list) or dataset.type!="ProbeSet": return [] - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: with conn.cursor() as cursor: query = """ @@ -99,7 +98,7 @@ def chunk_dataset(dataset, steps, name): ProbeSetXRef.ProbeSetId = ProbeSet.Id """.format(name) - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: with conn.cursor() as curr: curr.execute(query) traits_name_dict = dict(curr.fetchall()) @@ -123,7 +122,7 @@ def compute_top_n_sample(start_vars, dataset, trait_list): sample_data=json.loads(samples_vals), dataset_samples=dataset.group.all_samples_ordered()) - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: with conn.cursor() as curr: curr.execute( """ @@ -141,7 +140,7 @@ def compute_top_n_sample(start_vars, dataset, trait_list): if len(trait_list) == 0: return {} - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: with conn.cursor() as curr: # fetching strain data in bulk query = ( @@ -177,7 +176,7 @@ def compute_top_n_lit(corr_results, target_dataset, this_trait) -> dict: geneid_dict = {trait_name: geneid for (trait_name, geneid) in geneid_dict.items() if corr_results.get(trait_name)} - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: return reduce( lambda acc, corr: {**acc, **corr}, compute_all_lit_correlation( @@ -252,7 +251,7 @@ def __compute_sample_corr__( if target_dataset.type == "ProbeSet" and start_vars.get("use_cache") == "true": - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: file_path = fetch_text_file(target_dataset.name, conn) if file_path: (sample_vals, target_data) = read_text_file( @@ -339,7 +338,7 @@ def __compute_lit_corr__( (this_trait_geneid, geneid_dict, species) = do_lit_correlation( this_trait, target_dataset) - with database_connection(current_app.config["SQL_URI"]) as conn: + with database_connection(SQL_URI) as conn: return reduce( lambda acc, lit: {**acc, **lit}, compute_all_lit_correlation( |