aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/trait.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-06-15 14:40:37 +0300
committerFrederick Muriuki Muriithi2023-06-20 13:36:50 +0300
commitaa4d213692cb27a903fe1593e2dd3387e638b350 (patch)
treef41cfdf7e369cae767af5534cfc02c9998b9e4a2 /wqflask/base/trait.py
parenta56d857dc1f6dbc25819a4af116139a2f3e14a68 (diff)
downloadgenenetwork2-aa4d213692cb27a903fe1593e2dd3387e638b350.tar.gz
Configs: Introduce Blueprints. Refactor configs in webqtlConfig.
* Introduce flask Blueprints to help with decoupling the various modules from the `wqflask/__init__.py` module * Refactor settings: Create a function `base.webqtlConfig.init_app(...)` to handle setting up the configurations on the app correctly. Call this function at app creation time. * Move configuration utility functions from `utility.tools` module to `utility.configuration` module. * Use the `get_setting(...)` function to retrieve configuration settings from the application.
Diffstat (limited to 'wqflask/base/trait.py')
-rw-r--r--wqflask/base/trait.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 37085448..70afa2cc 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -1,22 +1,21 @@
import requests
import simplejson as json
-from wqflask import app
+
+from flask import g, request, url_for, Blueprint, current_app as app
import utility.hmac as hmac
from base import webqtlConfig
from base.webqtlCaseData import webqtlCaseData
from base.data_set import create_dataset
from utility.authentication_tools import check_resource_availability
-from utility.tools import GN2_BASE_URL
+from utility.configuration import get_setting
from utility.redis_tools import get_redis_conn, get_resource_id
-from flask import g, request, url_for
-
from wqflask.database import database_connection
Redis = get_redis_conn()
-
+trait_bp = Blueprint("trait", __name__)
def create_trait(**kw):
assert bool(kw.get('dataset')) != bool(
@@ -173,11 +172,14 @@ class GeneralTrait:
alias = 'Not available'
if self.symbol:
human_response = requests.get(
- GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.upper())
+ get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" +
+ self.symbol.upper())
mouse_response = requests.get(
- GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.capitalize())
+ get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" +
+ self.symbol.capitalize())
other_response = requests.get(
- GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.lower())
+ get_setting("GN2_BASE_URL") + "gn3/gene/aliases/" +
+ self.symbol.lower())
if human_response and mouse_response and other_response:
alias_list = json.loads(human_response.content) + json.loads(
@@ -254,7 +256,7 @@ def retrieve_sample_data(trait, dataset, samplelist=None):
return trait
-@app.route("/trait/get_sample_data")
+@trait_bp.route("/trait/get_sample_data")
def get_sample_data():
params = request.args
trait = params['trait']