From fdf9061981ce5d341d178951adeb19dd0376ee66 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 24 May 2022 14:19:57 +0300 Subject: Run partial correlations with external script Use new external script to run the partial correlations for both cases, i.e. - against an entire dataset, or - against selected traits --- gn3/api/correlation.py | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'gn3/api') diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py index 3aadcb9..1667302 100644 --- a/gn3/api/correlation.py +++ b/gn3/api/correlation.py @@ -16,8 +16,6 @@ from gn3.computations.correlations import map_shared_keys_to_values from gn3.computations.correlations import compute_tissue_correlation from gn3.computations.correlations import compute_all_lit_correlation from gn3.computations.correlations import compute_all_sample_correlation -from gn3.computations.partial_correlations import ( - partial_correlations_with_target_traits) correlation = Blueprint("correlation", __name__) @@ -124,16 +122,25 @@ def partial_correlation(): "messages": request_errors, "error_type": "Client Error"}) - if with_target_db: - with redis.Redis() as conn: - queueing_results = run_async_cmd( + with redis.Redis() as conn: + if with_target_db: + command = compose_pcorrs_command( + trait_fullname(args["primary_trait"]), + tuple( + trait_fullname(trait) for trait in args["control_traits"]), + args["method"], target_database=args["target_db"], + criteria = int(args.get("criteria", 500))) + else: + command = compose_pcorrs_command( + trait_fullname(args["primary_trait"]), + tuple( + trait_fullname(trait) for trait in args["control_traits"]), + args["method"], target_traits=tuple( + trait_fullname(trait) for trait in args["target_traits"])) + + queueing_results = run_async_cmd( conn=conn, - cmd=compose_pcorrs_command( - trait_fullname(args["primary_trait"]), - tuple( - trait_fullname(trait) for trait in args["control_traits"]), - args["method"], args["target_db"], - int(args.get("criteria", 500))), + cmd=command, job_queue=current_app.config.get("REDIS_JOB_QUEUE"), env = {"PYTHONPATH": ":".join(sys.path), "SQL_URI": SQL_URI}) return build_response({ @@ -141,15 +148,3 @@ def partial_correlation(): "results": queueing_results, "queued": True }) - - with database_connector() as conn: - results = partial_correlations_with_target_traits( - conn, - trait_fullname(args["primary_trait"]), - tuple( - trait_fullname(trait) for trait in args["control_traits"]), - args["method"], - tuple( - trait_fullname(trait) for trait in args["target_traits"])) - - return build_response({"status": "success", "results": results}) -- cgit v1.2.3