aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/wgcna.py
blob: fa044cf128f239f9f3b5055cd2276829b2c89887 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""endpoint to run wgcna analysis"""
from flask import Blueprint
from flask import request
from flask import current_app
from flask import jsonify

from gn3.computations.wgcna import call_wgcna_script

wgcna = Blueprint("wgcna", __name__)


@wgcna.route("/run_wgcna", methods=["POST"])
def run_wgcna():
    """run wgcna:output should be a json with a the data"""

    wgcna_data = request.json

    wgcna_script = current_app.config["WGCNA_RSCRIPT"]

    results = call_wgcna_script(wgcna_script, wgcna_data)

    if results.get("data") is None:
        return jsonify(results), 401

    return jsonify(results), 200