aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-12-22 09:29:11 +0300
committerFrederick Muriuki Muriithi2021-12-24 14:36:14 +0300
commited8ee3077211cc227089f87929a70ac8b7c4593f (patch)
tree07797a18db7ef081b8918fff0cfbe7068ca63a22 /gn3/api
parentfa227ea35710658c7d8314315ee072a641c163f9 (diff)
downloadgenenetwork3-ed8ee3077211cc227089f87929a70ac8b7c4593f.tar.gz
Add API endpoint for partial correlations
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Add an API endpoint for the partial correlation. * gn3/api/correlation.py:
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/correlation.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/gn3/api/correlation.py b/gn3/api/correlation.py
index e936eaf..f84228a 100644
--- a/gn3/api/correlation.py
+++ b/gn3/api/correlation.py
@@ -1,4 +1,6 @@
"""Endpoints for running correlations"""
+import json
+
from flask import jsonify
from flask import Blueprint
from flask import request
@@ -87,9 +89,20 @@ def compute_tissue_corr(corr_method="pearson"):
@correlation.route("/partial", methods=["POST"])
def partial_correlation():
+ """API endpoint for partial correlations."""
def trait_fullname(trait):
return f"{trait['dataset']}::{trait['name']}"
+ class OutputEncoder(json.JSONEncoder):
+ """
+ Class to encode output into JSON, for objects which the default
+ json.JSONEncoder class does not have default encoding for.
+ """
+ def default(self, obj):
+ if isinstance(obj, bytes):
+ return str(obj, encoding="utf-8")
+ return json.JSONEncoder.default(self, obj)
+
args = request.get_json()
conn, _cursor_object = database_connector()
corr_results = partial_correlations_entry(