From 537e1d19d33f1000103f3f33b52e87674ca89a31 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 28 Jun 2016 11:03:06 +0000 Subject: Logger: disabled some noisy loggers --- wqflask/wqflask/show_trait/SampleList.py | 4 ++-- wqflask/wqflask/show_trait/show_trait.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index 5e3b092e..7e7503d4 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -32,7 +32,7 @@ class SampleList(object): self.sample_attribute_values = {} self.get_attributes() - logger.debug("camera: attributes are:", pf(self.attributes)) + # logger.debug("camera: attributes are:", pf(self.attributes)) if self.this_trait and self.dataset and self.dataset.type == 'ProbeSet': self.get_extra_attribute_values() @@ -55,7 +55,7 @@ class SampleList(object): sample.extra_info['url'] = "/mouseCross.html#AXB/BXA" sample.extra_info['css_class'] = "fs12" - logger.debug(" type of sample:", type(sample)) + # logger.debug(" type of sample:", type(sample)) if sample_group_type == 'primary': sample.this_id = "Primary_" + str(counter) diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 3eea3f4a..912beabe 100644 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -146,7 +146,7 @@ class ShowTrait(object): else: self.sample_group_types['samples_primary'] = self.dataset.group.name sample_lists = [group.sample_list for group in self.sample_groups] - logger.debug("sample_lists is:", pf(sample_lists)) + # logger.debug("sample_lists is:", pf(sample_lists)) self.get_mapping_methods() -- cgit v1.2.3 From 0e975e62810c1b8afac13e1fa039a3998fc58ba9 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 16 Jul 2016 12:00:55 +0600 Subject: README: added info --- doc/Architecture.org | 5 +++-- wqflask/maintenance/README.md | 4 ++++ wqflask/maintenance/__init__.py | 0 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 wqflask/maintenance/README.md delete mode 100644 wqflask/maintenance/__init__.py (limited to 'wqflask') diff --git a/doc/Architecture.org b/doc/Architecture.org index 9a561568..cac40939 100644 --- a/doc/Architecture.org +++ b/doc/Architecture.org @@ -56,7 +56,6 @@ from the database. To get the menu data in YAML you can do something like see [[https://github.com/genenetwork/gn_server/doc/API.md][GnServer REST API]] documentation. * Database - ** Phenotypes Phenotypes are stored in the SQL database. For what happens at the @@ -67,7 +66,7 @@ see the installation [[./README.org][instructions]]. Genotypes are stored in genotype files. These are part of the GNU Guix distribution, see the installation [[./README.org][instructions]]. Genotype files are -currently in GN1 format, and will be aligned with the R/qtl2 format. Now it is +currently in GN1 format, and will be aligned with the [[http://kbroman.org/qtl2/pages/sampledata.html][R/qtl2 formats]]. Now it is for BXD.geno: #+begin_src js @@ -93,3 +92,5 @@ B B B B B B D B D B B D B B H H B D B B H H B B D D D D D B B H B B B B D B D B D D D D D H B D D B D B B D D B D D B B B B B B U D etc #+end_src + +and, for example, in the method run_rqtl_geno this file gets loaded. diff --git a/wqflask/maintenance/README.md b/wqflask/maintenance/README.md new file mode 100644 index 00000000..873eaa32 --- /dev/null +++ b/wqflask/maintenance/README.md @@ -0,0 +1,4 @@ +Maintenance files have been moved into a separate repository named +*gn_extra*. See https://github.com/genenetwork/gn_extra + + diff --git a/wqflask/maintenance/__init__.py b/wqflask/maintenance/__init__.py deleted file mode 100644 index e69de29b..00000000 -- cgit v1.2.3 From 41a8f2381b0d2d2f7d6aa5d50dee93d96af3ff39 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Tue, 26 Jul 2016 10:49:46 +0600 Subject: Docs: genotype --- doc/Architecture.org | 19 ++++++++++--------- .../marker_regression/marker_regression_gn1.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'wqflask') diff --git a/doc/Architecture.org b/doc/Architecture.org index e3bc8026..a1fcbef2 100644 --- a/doc/Architecture.org +++ b/doc/Architecture.org @@ -66,8 +66,9 @@ see the installation [[./README.org][instructions]]. Genotypes are stored in genotype files. These are part of the GNU Guix distribution, see the installation [[./README.org][instructions]]. Genotype files are -currently in GN1 format, and will be aligned with the [[http://kbroman.org/qtl2/pages/sampledata.html][R/qtl2 -formats]]. Currently it is for the stored file BXD.geno: +currently in GN1 format, and will be aligned with the [[http://kbroman.org/qtl2/pages/sampledata.html][R/qtl2 formats]]. + +GN1-style (still default GN2) for the stored file BXD.geno: #+begin_src js @name:BXD @@ -130,21 +131,21 @@ genotype data is tagged as transposed: "founder_geno": "recla_foundergeno.csv", "founder_geno_transposed": true, "genotypes": { -"1": "1", -"2": "2", -"3": "3" + "1": "1", + "2": "2", + "3": "3" }, "pheno": "recla_pheno.csv", "pheno_transposed": false, "covar": "recla_covar.csv", "sex": { -"covar": "Sex", -"female": "female", -"male": "male" + "covar": "Sex", + "female": "female", + "male": "male" }, "x_chr": "X", "cross_info": { -"covar": "ngen" + "covar": "ngen" }, "gmap": "recla_gmap.csv", "pmap": "recla_pmap.csv", diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index 9573a9de..33ebc527 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -382,7 +382,7 @@ class MarkerRegression(object): self.GraphInterval = self.MbGraphInterval #Mb else: self.GraphInterval = self.cMGraphInterval #cM - + ################################################################ # Get Trait Values and Infomation ################################################################ -- cgit v1.2.3 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 --- bin/genenetwork2 | 27 ++++++++++++++++++++++++--- wqflask/base/data_set.py | 2 +- wqflask/base/webqtlConfig.py | 1 - wqflask/maintenance/gen_select_dataset.py | 26 +++++++++++++++++--------- wqflask/utility/tools.py | 1 + 5 files changed, 43 insertions(+), 14 deletions(-) (limited to 'wqflask') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index d3bf3299..3a8c3ff4 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -1,6 +1,14 @@ #! /bin/bash # -# This will run the GN2 server (with default settings if none supplied). +# This will run the GN2 server (with default settings if none supplied). Pass in +# your own settings file, e.g. +# +# ./bin/genenetwork2 ~/my_settings.py +# +# To run a maintenance script with settings (instead of the webserver) add that with +# a -c switch, e.g. +# +# ./bin/genenetwork2 ~/my_settings.py -c ./wqflask/maintenance/gen_select_dataset.py # # Environment settings can be used to preconfigure as well as a # settings.py file. @@ -18,7 +26,12 @@ echo $GN2_BASE_PATH # Handle settings parameter settings=$1 -if [ -z $settings ]; then settings=$GN2_BASE_PATH/etc/default_settings.py ; fi +if [ -z $settings ]; then + # get default + settings=$GN2_BASE_PATH/etc/default_settings.py +else + shift +fi if [ ! -e $settings ]; then echo "ERROR: can not locate settings file - pass it in the command line" exit 1 @@ -32,7 +45,15 @@ export PYTHONPATH=$GN2_BASE_PATH/wqflask:$PYTHONPATH if [ -z $TEMPDIR ]; then TEMPDIR="/tmp" fi - + +# Now handle command parameter -c +if [ $1 = '-c' ] ; then + echo PYTHONPATH=$PYTHONPATH + echo RUNNING COMMAND $2 + /usr/bin/env python $2 + exit 0 +fi + echo "Starting the redis server:" echo -n "dir $TEMPDIR dbfilename gn2.rdb diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 1b4e1195..6cd3c8e6 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/static/new/javascript/dataset_menu_structure.json" + file_name = "wqflask/wqflask/static/new/javascript/dataset_menu_structure.json" with open(file_name, 'r') as fh: data = json.load(fh) diff --git a/wqflask/base/webqtlConfig.py b/wqflask/base/webqtlConfig.py index f76d8140..8c67a6fd 100644 --- a/wqflask/base/webqtlConfig.py +++ b/wqflask/base/webqtlConfig.py @@ -80,4 +80,3 @@ PORTADDR = "http://50.16.251.170" INFOPAGEHREF = '/dbdoc/%s.html' CGIDIR = '/webqtl/' #XZ: The variable name 'CGIDIR' should be changed to 'PYTHONDIR' SCRIPTFILE = 'main.py' - 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() diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index bb8241f5..2c8cc5c5 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -3,6 +3,7 @@ import os import sys + from wqflask import app # Use the standard logger here to avoid a circular dependency -- cgit v1.2.3 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') 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 v1.2.3