aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-05-06 16:43:26 +0300
committerFrederick Muriuki Muriithi2022-05-06 16:43:26 +0300
commit4a9fd93d01b6d4bd9d9880dbf2274b3c7f2de37b (patch)
tree088287b7e1e65399529a405377968905c5017c01 /gn3/api
parentd04241d0e49a50d9aa775042fffe5a7d8cfaf551 (diff)
downloadgenenetwork3-4a9fd93d01b6d4bd9d9880dbf2274b3c7f2de37b.tar.gz
Fix linting and typing errors
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/correlation.py35
1 files changed, 16 insertions, 19 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py
index aeb7f8c..44aaf56 100644
--- a/gn3/api/correlation.py
+++ b/gn3/api/correlation.py
@@ -114,13 +114,10 @@ def partial_correlation():
args = request.get_json()
with_target_db = args.get("with_target_db", True)
- request_errors = None
- if with_target_db:
- request_errors = __errors__(
- args, ("primary_trait", "control_traits", "target_db", "method"))
- else:
- request_errors = __errors__(
- args, ("primary_trait", "control_traits", "target_traits", "method"))
+ request_errors = __errors__(
+ args, ("primary_trait", "control_traits",
+ ("target_db" if with_target_db else "target_traits"),
+ "method"))
if request_errors:
return build_response({
"status": "error",
@@ -140,15 +137,15 @@ def partial_correlation():
int(args.get("criteria", 500))),
job_queue=current_app.config.get("REDIS_JOB_QUEUE"),
env = {"PYTHONPATH": ":".join(sys.path), "SQL_URI": SQL_URI})})
- else:
- 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"]),
- tuple(
- trait_fullname(trait) for trait in args["target_traits"]),
- args["method"])
-
- return build_response({"status": "success", "results": results})
+
+ 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"]),
+ tuple(
+ trait_fullname(trait) for trait in args["target_traits"]),
+ args["method"])
+
+ return build_response({"status": "success", "results": results})