From ec7d4e1198bc8d2f83ce99b41e2084fbce6a0be7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 10 Sep 2016 11:43:21 +0200 Subject: Support for running maintenance scripts so they can pick up all webserver settings Run with ./bin/genenetwork2 ~/my_settings.py -c ./wqflask/maintenance/gen_select_dataset.py --- wqflask/maintenance/gen_select_dataset.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'wqflask/maintenance') diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index d39bf4a5..5c25c15b 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -1,7 +1,9 @@ """Script that generates the data for the main dropdown menus on the home page Writes out data as /static/new/javascript/dataset_menu_structure.json -It needs to be run manually when database has been changed. +It needs to be run manually when database has been changed. Run it as + + python gen_select_dataset.py """ @@ -37,9 +39,15 @@ from __future__ import print_function, division #print("cdict is:", cdict) import sys -# import zach_settings # no hard code paths! -# import MySQLdb +# NEW: Note we prepend the current path - otherwise a guix instance of GN2 is used instead +sys.path.insert(0,'./wqflask') +# NEW: import app to avoid a circular dependency on utility.tools +from wqflask import app + +from utility.tools import locate, locate_ignore_error, TEMPDIR, SQL_URI + +import MySQLdb # import simplejson as json import urlparse @@ -55,14 +63,13 @@ from pprint import pformat as pf #conn = Engine.connect() -print('ERROR: This conversion is now OBSOLETE as the menu gets built from the database in Javascript using GN_SERVER instead!') -sys.exit() +print('WARNING: This conversion is now OBSOLETE as the menu gets built from the database in Javascript using GN_SERVER instead!') def parse_db_uri(db_uri): """Converts a database URI to the db name, host name, user name, and password""" - parsed_uri = urlparse.urlparse(zach_settings.DB_URI) + parsed_uri = urlparse.urlparse(SQL_URI) db_conn_info = dict( db = parsed_uri.path[1:], @@ -70,6 +77,7 @@ def parse_db_uri(db_uri): user = parsed_uri.username, passwd = parsed_uri.password) + print(db_conn_info) return db_conn_info @@ -258,7 +266,7 @@ def build_datasets(species, group, type_name): def main(): """Generates and outputs (as json file) the data for the main dropdown menus on the home page""" - parse_db_uri(zach_settings.SQL_URI) + parse_db_uri(SQL_URI) species = get_species() groups = get_groups(species) @@ -281,7 +289,7 @@ def main(): #print("data:", data) - output_file = """../wqflask/static/new/javascript/dataset_menu_structure.json""" + output_file = """./wqflask/wqflask/static/new/javascript/dataset_menu_structure.json""" with open(output_file, 'w') as fh: json.dump(data, fh, indent=" ", sort_keys=True) @@ -297,6 +305,6 @@ def _test_it(): #print("build_datasets:", pf(datasets)) if __name__ == '__main__': - Conn = MySQLdb.Connect(**parse_db_uri(zach_settings.SQL_URI)) + Conn = MySQLdb.Connect(**parse_db_uri(SQL_URI)) Cursor = Conn.cursor() main() -- cgit 1.4.1 From 5e106bad6e59d3a13be0b79715785948a3ff581a Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 10 Sep 2016 11:57:55 +0200 Subject: Comment --- wqflask/maintenance/gen_select_dataset.py | 2 +- wqflask/wqflask/marker_regression/marker_regression.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'wqflask/maintenance') diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index 5c25c15b..f2f0830f 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -3,7 +3,7 @@ Writes out data as /static/new/javascript/dataset_menu_structure.json It needs to be run manually when database has been changed. Run it as - python gen_select_dataset.py + ./bin/genenetwork2 ~/my_settings.py -c ./wqflask/maintenance/gen_select_dataset.py """ diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index f3b018b8..a1065adc 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -57,7 +57,7 @@ class MarkerRegression(object): all_samples_ordered = self.dataset.group.all_samples_ordered() primary_sample_names = list(all_samples_ordered) - + for sample in self.dataset.group.samplelist: in_trait_data = False for item in self.this_trait.data: @@ -241,9 +241,9 @@ class MarkerRegression(object): highest_chr = marker['chr'] if ('lod_score' in marker.keys()) or ('lrs_value' in marker.keys()): self.qtl_results.append(marker) - + self.trimmed_markers = trim_markers_for_table(results) - + self.json_data['chr'] = [] self.json_data['pos'] = [] self.json_data['lod.hk'] = [] @@ -560,7 +560,7 @@ class MarkerRegression(object): def gen_pheno_txt_file_plink(self, pheno_filename = ''): - ped_sample_list = self.get_samples_from_ped_file() + ped_sample_list = self.get_samples_from_ped_file() output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb") header = 'FID\tIID\t%s\n' % self.this_trait.name output_file.write(header) @@ -595,7 +595,7 @@ class MarkerRegression(object): output_file.close() def gen_pheno_txt_file_rqtl(self, pheno_filename = ''): - ped_sample_list = self.get_samples_from_ped_file() + ped_sample_list = self.get_samples_from_ped_file() output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb") header = 'FID\tIID\t%s\n' % self.this_trait.name output_file.write(header) @@ -653,7 +653,7 @@ class MarkerRegression(object): genotype = genotype.addinterval() samples, values, variances, sample_aliases = self.this_trait.export_informative() - + trimmed_samples = [] trimmed_values = [] for i in range(0, len(samples)): @@ -818,7 +818,7 @@ class MarkerRegression(object): """Runs permutations and gets significant and suggestive LOD scores""" top_lod_scores = [] - + #print("self.num_perm:", self.num_perm) for permutation in range(self.num_perm): @@ -1084,7 +1084,7 @@ def create_snp_iterator_file(group): def trim_markers_for_table(markers): num_markers = len(markers) - + if 'lod_score' in markers[0].keys(): sorted_markers = sorted(markers, key=lambda k: k['lod_score'], reverse=True) else: -- cgit 1.4.1 From f399b3bf514b396de67644d4b1e2018886cecac2 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 13 Sep 2016 09:09:21 +0200 Subject: Run scripts from ./wqflask - just like the webserver --- bin/genenetwork2 | 9 +++++---- wqflask/base/data_set.py | 2 +- wqflask/maintenance/gen_select_dataset.py | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'wqflask/maintenance') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index 3a8c3ff4..d926d6a1 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -13,13 +13,12 @@ # Environment settings can be used to preconfigure as well as a # settings.py file. -# Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=$(readlink -f "$0") -# Absolute path this script is in, thus /home/user/bin GN2_BASE_PATH=$(dirname $(dirname "$SCRIPT")) GN2_GUIX_PATH=$GN2_BASE_PATH/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg if [ -d $GN2_GUIX_PATH ]; then + echo GN2 is running from GUIX GN2_BASE_PATH=$GN2_GUIX_PATH fi echo $GN2_BASE_PATH @@ -48,9 +47,11 @@ fi # Now handle command parameter -c if [ $1 = '-c' ] ; then + cd $GN2_BASE_PATH/wqflask + cmd=${2#wqflask/} echo PYTHONPATH=$PYTHONPATH - echo RUNNING COMMAND $2 - /usr/bin/env python $2 + echo RUNNING COMMAND $cmd + /usr/bin/env python $cmd exit 0 fi diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 6cd3c8e6..1b4e1195 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -91,7 +91,7 @@ Publish or ProbeSet. E.g. if USE_GN_SERVER: data = menu_main() else: - file_name = "wqflask/wqflask/static/new/javascript/dataset_menu_structure.json" + file_name = "wqflask/static/new/javascript/dataset_menu_structure.json" with open(file_name, 'r') as fh: data = json.load(fh) diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index f2f0830f..23adc4f9 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -40,8 +40,8 @@ from __future__ import print_function, division import sys -# NEW: Note we prepend the current path - otherwise a guix instance of GN2 is used instead -sys.path.insert(0,'./wqflask') +# NEW: Note we prepend the current path - otherwise a guix instance of GN2 may be used instead +sys.path.insert(0,'./') # NEW: import app to avoid a circular dependency on utility.tools from wqflask import app -- cgit 1.4.1 From 909a1cca82d86f824c6778b59b2ee339a7ee8ffd Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 13 Sep 2016 16:13:13 +0000 Subject: Fixed the path for the json file in gen_select_dataset.py since it was wrong and uncommented simplejson import Added "Reset" option to network graph that returns all the nodes/edges Made the visualization options area in the network graph a little wider --- wqflask/maintenance/gen_select_dataset.py | 4 +- wqflask/wqflask/network_graph/network_graph.py | 9 +- wqflask/wqflask/static/new/css/network_graph.css | 2 +- .../new/javascript/dataset_menu_structure.json | 178 ++++++++++++--------- .../wqflask/static/new/javascript/network_graph.js | 11 +- wqflask/wqflask/templates/network_graph.html | 7 +- 6 files changed, 128 insertions(+), 83 deletions(-) (limited to 'wqflask/maintenance') diff --git a/wqflask/maintenance/gen_select_dataset.py b/wqflask/maintenance/gen_select_dataset.py index 23adc4f9..542c0d83 100644 --- a/wqflask/maintenance/gen_select_dataset.py +++ b/wqflask/maintenance/gen_select_dataset.py @@ -49,7 +49,7 @@ from utility.tools import locate, locate_ignore_error, TEMPDIR, SQL_URI import MySQLdb -# import simplejson as json +import simplejson as json import urlparse @@ -289,7 +289,7 @@ def main(): #print("data:", data) - output_file = """./wqflask/wqflask/static/new/javascript/dataset_menu_structure.json""" + output_file = """./wqflask/static/new/javascript/dataset_menu_structure.json""" with open(output_file, 'w') as fh: json.dump(data, fh, indent=" ", sort_keys=True) diff --git a/wqflask/wqflask/network_graph/network_graph.py b/wqflask/wqflask/network_graph/network_graph.py index 1d725c4c..cebe5c03 100644 --- a/wqflask/wqflask/network_graph/network_graph.py +++ b/wqflask/wqflask/network_graph/network_graph.py @@ -167,9 +167,9 @@ class NetworkGraph(object): if abs(sample_r) > max_corr: max_corr = abs(sample_r) - edge_data = {'id' : this_trait.name + '_to_' + target_trait.name, - 'source' : this_trait.name + ":" + this_trait.dataset.name, - 'target' : target_trait.name + ":" + target_trait.dataset.name, + edge_data = {'id' : str(this_trait.name) + '_to_' + str(target_trait.name), + 'source' : str(this_trait.name) + ":" + str(this_trait.dataset.name), + 'target' : str(target_trait.name) + ":" + str(target_trait.dataset.name), 'correlation' : round(sample_r, 3), 'abs_corr' : abs(round(sample_r, 3)), 'p_value' : round(sample_p, 3), @@ -181,8 +181,9 @@ class NetworkGraph(object): self.edges_list.append(edge_dict) - node_dict = { 'data' : {'id' : this_trait.name + ":" + this_trait.dataset.name, + node_dict = { 'data' : {'id' : str(this_trait.name) + ":" + str(this_trait.dataset.name), 'label' : this_trait.name, + 'symbol' : this_trait.symbol, 'geneid' : this_trait.geneid, 'omim' : this_trait.omim, 'max_corr' : max_corr } } diff --git a/wqflask/wqflask/static/new/css/network_graph.css b/wqflask/wqflask/static/new/css/network_graph.css index c01c0d24..1cba546a 100644 --- a/wqflask/wqflask/static/new/css/network_graph.css +++ b/wqflask/wqflask/static/new/css/network_graph.css @@ -13,7 +13,7 @@ #secondaryContent { position: relative; float: left; - width: 16.5em; + width: 18.5em; padding: 1em 1em 1em 1em; background: #fff url('/static/new/images/a1.gif') top right repeat-y; } diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json index 750a9118..d3db1853 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json +++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json @@ -317,6 +317,30 @@ ] }, "GTEx": { + "Adipose tissue, subcutaneous mRNA": [ + [ + "580", + "GTEx_log2_Subcu_0314", + "GTEx Human Subcutaneous (Mar14) RPKM Log2" + ], + [ + "530", + "GTEx_Subcu_0414", + "GTEx Human Subcutaneous (Apr14) RPKM" + ] + ], + "Adipose tissue, visceral mRNA": [ + [ + "587", + "GTEx_log2_Visce_0314", + "GTEx Human Visceral (Mar14) RPKM Log2" + ], + [ + "537", + "GTEx_Visce_0414", + "GTEx Human Visceral (Apr14) RPKM" + ] + ], "Adrenal Gland mRNA": [ [ "545", @@ -773,18 +797,6 @@ "GTEx Human Stomach (Apr14) RPKM" ] ], - "Subcutaneous mRNA": [ - [ - "580", - "GTEx_log2_Subcu_0314", - "GTEx Human Subcutaneous (Mar14) RPKM Log2" - ], - [ - "530", - "GTEx_Subcu_0414", - "GTEx Human Subcutaneous (Apr14) RPKM" - ] - ], "Substantia Nigra mRNA": [ [ "581", @@ -857,18 +869,6 @@ "GTEx Human Vagina (Apr14) RPKM" ] ], - "Visceral mRNA": [ - [ - "587", - "GTEx_log2_Visce_0314", - "GTEx Human Visceral (Mar14) RPKM Log2" - ], - [ - "537", - "GTEx_Visce_0414", - "GTEx Human Visceral (Apr14) RPKM" - ] - ], "Whole Blood mRNA": [ [ "588", @@ -883,6 +883,20 @@ ] }, "GTEx_v5": { + "Adipose tissue, subcutaneous mRNA": [ + [ + "718", + "GTEXv5_AdipSub_0915", + "GTEXv5 Human Adipose Subcutaneous RefSeq (Sep15) RPKM log2" + ] + ], + "Adipose tissue, visceral mRNA": [ + [ + "719", + "GTEXv5_AdiVis_0915", + "GTEXv5 Human Adipose Visceral Omentum RefSeq (Sep15) RPKM log2" + ] + ], "Adrenal Gland mRNA": [ [ "720", @@ -1191,13 +1205,6 @@ "GTEXv5 Human Stomach RefSeq (Sep15) RPKM log2" ] ], - "Subcutaneous mRNA": [ - [ - "718", - "GTEXv5_AdipSub_0915", - "GTEXv5 Human Adipose Subcutaneous RefSeq (Sep15) RPKM log2" - ] - ], "Substantia Nigra mRNA": [ [ "737", @@ -1240,13 +1247,6 @@ "GTEXv5 Human Vagina RefSeq (Sep15) RPKM log2" ] ], - "Visceral mRNA": [ - [ - "719", - "GTEXv5_AdiVis_0915", - "GTEXv5 Human Adipose Visceral Omentum RefSeq (Sep15) RPKM log2" - ] - ], "Whole Blood mRNA": [ [ "770", @@ -1609,8 +1609,29 @@ ] ] }, + "B6D2": { + "Phenotypes": [ + [ + "None", + "B6D2Publish", + "B6D2 Published Phenotypes" + ] + ], + "Retina mRNA": [ + [ + "803", + "UTHSC_mm9_B6D2_Ret_0916", + "UTHSC B6D2 Retina Affy MoGene 1.0ST (Sep16) Gene Level RMA" + ] + ] + }, "B6D2F2": { "Brain mRNA": [ + [ + "78", + "BRF2_M_0805_P", + "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" + ], [ "77", "BRF2_M_0805_R", @@ -1621,11 +1642,6 @@ "BRF2_M_0805_M", "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) MAS5" ], - [ - "78", - "BRF2_M_0805_P", - "OHSU/VA B6D2F2 Brain mRNA M430 (Aug05) PDNN" - ], [ "33", "BRF2_M_0304_P", @@ -2305,16 +2321,16 @@ ] ], "Kidney mRNA": [ - [ - "239", - "MA_M2F_0706_R", - "Mouse kidney M430v2 Female (Aug06) RMA" - ], [ "240", "MA_M2M_0706_R", "Mouse kidney M430v2 Male (Aug06) RMA" ], + [ + "239", + "MA_M2F_0706_R", + "Mouse kidney M430v2 Female (Aug06) RMA" + ], [ "118", "MA_M2_0806_R", @@ -2494,16 +2510,16 @@ ] ], "Neocortex mRNA": [ - [ - "375", - "DevNeocortex_ILM6.2P14RInv_1111", - "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov11) RankInv" - ], [ "374", "DevNeocortex_ILM6.2P3RInv_1111", "BIDMC/UTHSC Dev Neocortex P3 ILMv6.2 (Nov11) RankInv" ], + [ + "375", + "DevNeocortex_ILM6.2P14RInv_1111", + "BIDMC/UTHSC Dev Neocortex P14 ILMv6.2 (Nov11) RankInv" + ], [ "284", "HQFNeoc_1210v2_RankInv", @@ -3016,6 +3032,11 @@ ] ], "Hippocampus mRNA": [ + [ + "214", + "Illum_LXS_Hipp_NOE_1008", + "Hippocampus Illumina NOE (Oct08) RankInv beta" + ], [ "211", "Illum_LXS_Hipp_RSS_1008", @@ -3036,11 +3057,6 @@ "Illum_LXS_Hipp_RSE_1008", "Hippocampus Illumina RSE (Oct08) RankInv beta" ], - [ - "214", - "Illum_LXS_Hipp_NOE_1008", - "Hippocampus Illumina NOE (Oct08) RankInv beta" - ], [ "143", "Illum_LXS_Hipp_loess0807", @@ -3471,6 +3487,10 @@ "B6BTBRF2", "B6BTBRF2" ], + [ + "B6D2", + "Glaucoma and Aged Retina, UTHSC" + ], [ "B6D2F2", "B6D2F2" @@ -3792,6 +3812,14 @@ ] ], "GTEx": [ + [ + "Adipose tissue, subcutaneous mRNA", + "Adipose tissue, subcutaneous mRNA" + ], + [ + "Adipose tissue, visceral mRNA", + "Adipose tissue, visceral mRNA" + ], [ "Adrenal Gland mRNA", "Adrenal Gland mRNA" @@ -3944,10 +3972,6 @@ "Stomach mRNA", "Stomach mRNA" ], - [ - "Subcutaneous mRNA", - "Subcutaneous mRNA" - ], [ "Substantia Nigra mRNA", "Substantia Nigra mRNA" @@ -3972,16 +3996,20 @@ "Vagina mRNA", "Vagina mRNA" ], - [ - "Visceral mRNA", - "Visceral mRNA" - ], [ "Whole Blood mRNA", "Whole Blood mRNA" ] ], "GTEx_v5": [ + [ + "Adipose tissue, subcutaneous mRNA", + "Adipose tissue, subcutaneous mRNA" + ], + [ + "Adipose tissue, visceral mRNA", + "Adipose tissue, visceral mRNA" + ], [ "Adrenal Gland mRNA", "Adrenal Gland mRNA" @@ -4158,10 +4186,6 @@ "Stomach mRNA", "Stomach mRNA" ], - [ - "Subcutaneous mRNA", - "Subcutaneous mRNA" - ], [ "Substantia Nigra mRNA", "Substantia Nigra mRNA" @@ -4186,10 +4210,6 @@ "Vagina mRNA", "Vagina mRNA" ], - [ - "Visceral mRNA", - "Visceral mRNA" - ], [ "Whole Blood mRNA", "Whole Blood mRNA" @@ -4363,6 +4383,16 @@ "Liver mRNA" ] ], + "B6D2": [ + [ + "Phenotypes", + "Phenotypes" + ], + [ + "Retina mRNA", + "Retina mRNA" + ] + ], "B6D2F2": [ [ "Genotypes", diff --git a/wqflask/wqflask/static/new/javascript/network_graph.js b/wqflask/wqflask/static/new/javascript/network_graph.js index da90ae26..e8ca6be0 100644 --- a/wqflask/wqflask/static/new/javascript/network_graph.js +++ b/wqflask/wqflask/static/new/javascript/network_graph.js @@ -12,7 +12,7 @@ window.onload=function() { selector: 'node', style: { 'background-color': '#666', - 'label': 'data(id)', + 'label': 'data(symbol)', 'font-size': 10 } }, @@ -154,6 +154,15 @@ window.onload=function() { }); + $('#reset_graph').click(function() { + eles.restore() + $('#slide').val(0) + cy.layout({ name: $('select[name=layout_select]').val(), + fit: true, // whether to fit the viewport to the graph + padding: 25 // the padding on fit + }); + }); + $('select[name=focus_select]').change(function() { focus_trait = $(this).val() diff --git a/wqflask/wqflask/templates/network_graph.html b/wqflask/wqflask/templates/network_graph.html index ec3a7971..57426af7 100644 --- a/wqflask/wqflask/templates/network_graph.html +++ b/wqflask/wqflask/templates/network_graph.html @@ -20,6 +20,11 @@

Visualization Options

+ + + -- cgit 1.4.1
+ +
Focus Trait @@ -29,7 +34,7 @@