From be09d207ee4e2705e358102f8bdbcd1da7f70ca2 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Fri, 24 Apr 2020 16:06:36 -0500
Subject: Replaced hard-coded instances of GN2 urls with ones pulled from
settings file
---
wqflask/base/data_set.py | 4 ++--
wqflask/base/trait.py | 7 ++++---
wqflask/utility/tools.py | 2 ++
wqflask/wqflask/ctl/ctl_analysis.py | 4 +++-
wqflask/wqflask/do_search.py | 3 ++-
wqflask/wqflask/network_graph/network_graph.py | 2 ++
wqflask/wqflask/search_results.py | 3 ++-
wqflask/wqflask/static/new/javascript/ctl_graph.js | 8 +-------
wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js | 1 -
wqflask/wqflask/static/new/javascript/network_graph.js | 4 ++--
wqflask/wqflask/templates/ctl_results.html | 1 +
wqflask/wqflask/templates/index_page.html | 4 ++--
wqflask/wqflask/templates/index_page_orig.html | 4 ++--
wqflask/wqflask/templates/network_graph.html | 1 +
14 files changed, 26 insertions(+), 22 deletions(-)
(limited to 'wqflask')
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index fae62875..8652e6b7 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -56,7 +56,7 @@ from pprint import pformat as pf
from db.gn_server import menu_main
from db.call import fetchall,fetchone,fetch1
-from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists
+from utility.tools import USE_GN_SERVER, USE_REDIS, flat_files, flat_file_exists, GN2_BASE_URL
from utility.logger import getLogger
logger = getLogger(__name__ )
@@ -94,7 +94,7 @@ Publish or ProbeSet. E.g.
"""
self.datasets = {}
if rebuild: #ZS: May make this the only option
- data = json.loads(requests.get("http://gn2.genenetwork.org/api/v_pre1/gen_dropdown").content)
+ data = json.loads(requests.get(GN2_BASE_URL + "/api/v_pre1/gen_dropdown").content)
#data = gen_menu.gen_dropdown_json()
else:
file_name = "wqflask/static/new/javascript/dataset_menu_structure.json"
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 5525472e..e454c593 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -14,6 +14,7 @@ from base.data_set import create_dataset
from db import webqtlDatabaseFunction
from utility import webqtlUtil
from utility import hmac
+from utility.tools import GN2_BASE_URL
from wqflask import app
@@ -135,9 +136,9 @@ class GeneralTrait(object):
alias = 'Not available'
if self.symbol:
- human_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.upper())
- mouse_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.capitalize())
- other_response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + self.symbol.lower())
+ human_response = requests.get(GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.upper())
+ mouse_response = requests.get(GN2_BASE_URL + "gn3/gene/aliases/" + self.symbol.capitalize())
+ other_response = requests.get(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(mouse_response.content) + json.loads(other_response.content)
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py
index 0fbedccb..9354ece6 100644
--- a/wqflask/utility/tools.py
+++ b/wqflask/utility/tools.py
@@ -234,6 +234,8 @@ def show_settings():
GN_VERSION = get_setting('GN_VERSION')
HOME = get_setting('HOME')
WEBSERVER_MODE = get_setting('WEBSERVER_MODE')
+GN2_BASE_URL = get_setting('GN2_BASE_URL')
+GN2_BRANCH_URL = get_setting('GN2_BRANCH_URL')
GN_SERVER_URL = get_setting('GN_SERVER_URL')
SERVER_PORT = get_setting_int('SERVER_PORT')
SQL_URI = get_setting('SQL_URI')
diff --git a/wqflask/wqflask/ctl/ctl_analysis.py b/wqflask/wqflask/ctl/ctl_analysis.py
index 6fda02fd..4415b86a 100644
--- a/wqflask/wqflask/ctl/ctl_analysis.py
+++ b/wqflask/wqflask/ctl/ctl_analysis.py
@@ -20,7 +20,7 @@ from base import data_set
from base import trait as TRAIT
from utility import helper_functions
-from utility.tools import locate
+from utility.tools import locate, GN2_BRANCH_URL
from rpy2.robjects.packages import importr
@@ -56,6 +56,8 @@ class CTL(object):
self.edges_list = []
logger.info("Obtained pointers to CTL functions")
+ self.gn2_url = GN2_BRANCH_URL
+
def addNode(self, gt):
node_dict = { 'data' : {'id' : str(gt.name) + ":" + str(gt.dataset.name),
'sid' : str(gt.name),
diff --git a/wqflask/wqflask/do_search.py b/wqflask/wqflask/do_search.py
index 05caa100..b0ca5ced 100644
--- a/wqflask/wqflask/do_search.py
+++ b/wqflask/wqflask/do_search.py
@@ -13,6 +13,7 @@ import sys
# sys.path.append("..") Never in a running webserver
from db import webqtlDatabaseFunction
+from utility.tools import GN2_BASE_URL
import logging
from utility.logger import getLogger
@@ -919,7 +920,7 @@ def get_aliases(symbol, species):
return []
filtered_aliases = []
- response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases/" + symbol_string)
+ response = requests.get(GN2_BASE_URL + "/gn3/gene/aliases/" + symbol_string)
if response:
alias_list = json.loads(response.content)
diff --git a/wqflask/wqflask/network_graph/network_graph.py b/wqflask/wqflask/network_graph/network_graph.py
index a332db46..152e4168 100644
--- a/wqflask/wqflask/network_graph/network_graph.py
+++ b/wqflask/wqflask/network_graph/network_graph.py
@@ -47,6 +47,7 @@ from utility.TDCell import TDCell
from base.trait import GeneralTrait
from base import data_set
from utility import webqtlUtil, helper_functions, corr_result_helpers
+from utility.tools import GN2_BRANCH_URL
from db import webqtlDatabaseFunction
import utility.webqtlUtil #this is for parallel computing only.
from wqflask.correlation import correlation_functions
@@ -195,6 +196,7 @@ class NetworkGraph(object):
self.nodes_list.append(node_dict)
self.elements = json.dumps(self.nodes_list + self.edges_list)
+ self.gn2_url = GN2_BRANCH_URL
groups = []
for sample in self.all_sample_list:
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index 698389ab..8f702d58 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -28,6 +28,7 @@ from flask import render_template, Flask, g
from utility import formatting
from utility import hmac
+from utility.tools import GN2_BASE_URL
from utility.type_checking import is_float, is_int, is_str, get_float, get_int, get_string
from utility.logger import getLogger
@@ -295,7 +296,7 @@ def get_aliases(symbol_list, species):
symbols_string = ",".join(updated_symbols)
filtered_aliases = []
- response = requests.get("http://gn2.genenetwork.org/gn3/gene/aliases2/" + symbols_string)
+ response = requests.get(GN2_BASE_URL + "/gn3/gene/aliases2/" + symbols_string)
if response:
alias_lists = json.loads(response.content)
seen = set()
diff --git a/wqflask/wqflask/static/new/javascript/ctl_graph.js b/wqflask/wqflask/static/new/javascript/ctl_graph.js
index 94bd7e9d..bd950592 100644
--- a/wqflask/wqflask/static/new/javascript/ctl_graph.js
+++ b/wqflask/wqflask/static/new/javascript/ctl_graph.js
@@ -82,18 +82,12 @@ window.onload=function() {
function create_qtips(cy){
cy.nodes().qtip({
content: function(){
- gn_link = ''+''+this.data().id +''+'
'
+ gn_link = ''+''+this.data().id +''+'
'
ncbi_link = 'NCBI'+'
'
omim_link = 'OMIM'+'
'
qtip_content = gn_link + ncbi_link + omim_link
return qtip_content
- //return ''+''+this.data().id +''+''
},
- // content: {
- // title: ''+''+this.target() +''+'',
- // text: this.target,
- // button: true
- // },
position: {
my: 'top center',
at: 'bottom center'
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
index fad600d2..794804f4 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
@@ -74,7 +74,6 @@ redo_dropdown = function(dropdown, items) {
this_opt_group = null
for (_i = 0, _len = group_family_list.length; _i < _len; _i++) {
item = group_family_list[_i];
- console.log("THE ITEM:", item)
if (item[2] != "None" && current_family == ""){
current_family = item[2]
this_opt_group = $("