From c9a48705184c02f0b74b01bae1d0ed8d9328550a Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 20 Apr 2016 08:14:04 +0000 Subject: [PATCH 012/100] Adding configuration for running a default server --- etc/default_settings.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 etc/default_settings.py (limited to 'etc/default_settings.py') diff --git a/etc/default_settings.py b/etc/default_settings.py new file mode 100644 index 00000000..7aa24fce --- /dev/null +++ b/etc/default_settings.py @@ -0,0 +1,25 @@ +LOGFILE = "/var/log/genenetwork/wqflask.log" + +# This is needed because Flask turns key errors into a +# 400 bad request response with no exception/log +TRAP_BAD_REQUEST_ERRORS = True + +DB_URI = "mysql://gn2:default@localhost/db_webqtl" +SQLALCHEMY_DATABASE_URI = 'mysql://gn2:default@localhost/db_webqtl' + +# http://pythonhosted.org/Flask-Security/configuration.html +SECURITY_CONFIRMABLE = True +SECURITY_TRACKABLE = True +SECURITY_REGISTERABLE = True +SECURITY_RECOVERABLE = True + +SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" +SECURITY_POST_LOGIN_VIEW = "/thank_you" +SQLALCHEMY_POOL_RECYCLE = 3600 + +SERVER_PORT = 5003 +SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' + +# Path overrides for Genenetwork +# PYLMM_PATH = 'UNUSED' + -- cgit v1.2.3 From 82f731d11a870262b5d4ed693b86d7dcc40493a1 Mon Sep 17 00:00:00 2001 From: pjotrp Date: Sat, 13 Feb 2016 12:21:07 +0100 Subject: * ./bin/genenetwork2: New file --- bin/genenetwork2 | 15 +++++++++++++++ etc/default_settings.py | 1 - 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 bin/genenetwork2 (limited to 'etc/default_settings.py') diff --git a/bin/genenetwork2 b/bin/genenetwork2 new file mode 100755 index 00000000..9cac31d5 --- /dev/null +++ b/bin/genenetwork2 @@ -0,0 +1,15 @@ +#! /bin/bash +# +# This will run the server with default settings + +# 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 +SCRIPTPATH=$(dirname $(dirname "$SCRIPT")) +echo $SCRIPTPATH + +export PROFILE=$SCRIPTPATH +export PYTHONPATH=$PROFILE/wqflask:$PYTHONPATH +export WQFLASK_SETTINGS=$PROFILE/etc/default_settings.py + +/usr/bin/env python ./wqflask/runserver.py diff --git a/etc/default_settings.py b/etc/default_settings.py index 7aa24fce..0c7d7bad 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -12,7 +12,6 @@ SECURITY_CONFIRMABLE = True SECURITY_TRACKABLE = True SECURITY_REGISTERABLE = True SECURITY_RECOVERABLE = True - SECURITY_EMAIL_SENDER = "no-reply@genenetwork.org" SECURITY_POST_LOGIN_VIEW = "/thank_you" SQLALCHEMY_POOL_RECYCLE = 3600 -- cgit v1.2.3 From beb6a9360ecc9edca19692e4081efc15292fb7d1 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 20 Apr 2016 08:28:44 +0000 Subject: [PATCH 018/100] Find external tools: refactored code to work with GNU Guix --- etc/default_settings.py | 8 +- wqflask/utility/tools.py | 92 ++++++++++------------ .../wqflask/marker_regression/marker_regression.py | 8 +- 3 files changed, 56 insertions(+), 52 deletions(-) (limited to 'etc/default_settings.py') diff --git a/etc/default_settings.py b/etc/default_settings.py index 0c7d7bad..929bd687 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -1,3 +1,5 @@ +import os + LOGFILE = "/var/log/genenetwork/wqflask.log" # This is needed because Flask turns key errors into a @@ -20,5 +22,7 @@ SERVER_PORT = 5003 SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' # Path overrides for Genenetwork -# PYLMM_PATH = 'UNUSED' - +HOME=os.environ.get('HOME') +PYLMM_PATH = HOME+"/izip/git/opensource/python/pylmm_gn2/" +PLINK_PATH = HOME+"/.guix-profile/bin" +GEMMA_PATH = HOME+"/.guix-profile/bin" diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index b8a41f60..0db195df 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -9,76 +9,70 @@ import os import sys from wqflask import app -def get_setting(id,default,guess,get_valid_path): - """ - Resolve a setting from the environment or the global settings in app.config +def get_setting(id,default,guess,find_path): + """Resolve a setting from the environment or the global settings in + app.config, with get_valid_path is a function checking whether the + path points to an expected directory an returns the full path e.g. + + guess = os.environ.get('HOME')+'/pylmm' + get_setting('PYLMM_PATH',default,guess,get_valid_path) + + first tries the environment variable in +id+, next gets the Flask + app setting for the same +id+, next tries the path passed in with + +default+ and finally does an educated +guess+. + + In all, the environment overrides the others, next is the flask + setting, then the default and finally the guess (which is + $HOME/repo). A valid path is returned. If none is resolved an + exception is thrown. + + Note that we do not use the system path. This is on purpose + because it will mess up controlled (reproducible) deployment. The + proper way is to either use the GNU Guix defaults as listed in + etc/default_settings.py or override them yourself by creating a + different settings.py file (or setting the environment). + """ # ---- Check whether environment exists - path = get_valid_path(os.environ.get(id)) + path = find_path(os.environ.get(id)) # ---- Check whether setting exists setting = app.config.get(id) if not path: - path = get_valid_path(setting) + path = find_path(setting) # ---- Check whether default exists if not path: - path = get_valid_path(default) + path = find_path(default) # ---- Guess directory if not path: + guess = os.environ.get('HOME')+guess if not setting: setting = guess - path = get_valid_path(guess) + path = find_path(guess) if not path: - raise Exception(id+' '+setting+' path unknown or faulty (update settings.py?). '+id+' should point to the root of the git repository') - + raise Exception(id+' '+setting+' path unknown or faulty (update settings.py?). '+id+' should point to the path') return path -def pylmm_command(default=None): - """ - Return the path to the repository and the python command to call - """ - def get_valid_path(path): +def find_command(command,id1,default,guess): + def find_path(path): """Test for a valid repository""" if path: - sys.stderr.write("Trying PYLMM_PATH in "+path+"\n") - if path and os.path.isfile(path+'/pylmm_gn2/lmm.py'): + sys.stderr.write("Trying "+id1+" in "+path+"\n") + binary = str.split(command)[0] + if path and os.path.isfile(path+'/'+binary): return path else: None - guess = os.environ.get('HOME')+'/pylmm_gn2' - path = get_setting('PYLMM_PATH',default,guess,get_valid_path) - pylmm_command = 'python '+path+'/pylmm_gn2/lmm.py' - return path,pylmm_command - -def plink_command(default=None): - """ - Return the path to the repository and the python command to call - """ - def get_valid_path(path): - """Test for a valid repository""" - if path: - sys.stderr.write("Trying PLINK_PATH in "+path+"\n") - if path and os.path.isfile(path+'/plink'): - return path - else: - None + path = get_setting(id1,default,guess,find_path) + binary = path+'/'+command + sys.stderr.write("Found "+binary+"\n") + return path,binary - guess = os.environ.get('HOME')+'/plink_gemma' - path = get_setting('PLINK_PATH',default,guess,get_valid_path) - plink_command = path+'/plink' - return path,plink_command +def pylmm_command(default=None): + return find_command('pylmm_gn2/lmm.py',"PYLMM_PATH",default,'/pylmm2') def gemma_command(default=None): - def get_valid_path(path): - """Test for a valid repository""" - if path: - sys.stderr.write("Trying PLINK_PATH in "+path+"\n") - if path and os.path.isfile(path+'/plink'): - return path - else: - None + return find_command('gemma',"GEMMA_PATH",default,'/gemma') - guess = os.environ.get('HOME')+'/plink' - path = get_setting('PLINK_PATH',default,guess,get_valid_path) - gemma_command = path+'/gemma' - return path, gemma_command \ No newline at end of file +def plink_command(default=None): + return find_command('plink2',"PLINK_PATH",default,'/plink') diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index af320f65..a657510d 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -42,9 +42,15 @@ from wqflask.marker_regression import gemma_mapping #from wqflask.marker_regression import plink_mapping #from wqflask.marker_regression import rqtl_mapping +# Check for valid binary paths of pylmm, plink, rqtl etc. This code +# runs at startup, so a missing binary will balk before running the +# service + +GEMMA_PATH,GEMMA_COMMAND = gemma_command() PYLMM_PATH,PYLMM_COMMAND = pylmm_command() PLINK_PATH,PLINK_COMMAND = plink_command() -GEMMA_PATH,GEMMA_COMMAND = gemma_command() +# RQTL_PATH,RQTL_COMMAND = rqtl_command() + class MarkerRegression(object): -- cgit v1.2.3 From af7d0bca229f3ebaa80a16d1ce3a2bf1a8abd5df Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 20 Apr 2016 08:37:55 +0000 Subject: [PATCH 023/100] WIP fixing all paths --- README.md | 2 + doc/GUIX-Reproducible-from-source.org | 14 +++- doc/README.org | 23 +++++- etc/default_settings.py | 15 ++-- wqflask/base/data_set.py | 3 +- wqflask/utility/tools.py | 82 ++++++++++------------ wqflask/wqflask/database.py | 5 +- .../wqflask/marker_regression/marker_regression.py | 6 +- wqflask/wqflask/show_trait/show_trait.py | 10 +-- 9 files changed, 94 insertions(+), 66 deletions(-) (limited to 'etc/default_settings.py') diff --git a/README.md b/README.md index 3d95d05f..db495910 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Elissa Chesler, Jintao Wang, Kenneth Manly, Robert W. Williams, and colleagues. Code and primary web service managed by Dr. Robert W. Williams and the University of Tennessee Health Science Center, Memphis TN, USA. +Join #genenetwork on irc.freenode.net. + Email labwilliams@gmail.com or rwilliams@uthsc.edu Older version available on SourceForge http://sourceforge.net/projects/genenetwork/ diff --git a/doc/GUIX-Reproducible-from-source.org b/doc/GUIX-Reproducible-from-source.org index 871156ed..4399ea26 100644 --- a/doc/GUIX-Reproducible-from-source.org +++ b/doc/GUIX-Reproducible-from-source.org @@ -4,6 +4,7 @@ - [[#introduction][Introduction]] - [[#binary-deployment][Binary deployment]] - [[#from-source-deployment][From source deployment]] + - [[#create-archive][Create archive]] * Introduction @@ -33,10 +34,21 @@ Once that is done we can add the guix-bioinformatics path with : env GUIX_PACKAGE_PATH=../guix-bioinformatics command -such as +So +#+begin_src sh :lang bash #+begin_src sh :lang bash gn-stable-guix$ env GUIX_PACKAGE_PATH=../guix-bioinformatics ./pre-inst-env guix package -A genenetwork genenetwork1 1.0-d622c803b out ../guix-bioinformatics/gn/packages/bioinformatics.scm:163:2 genenetwork2 2.0-9e9475053 out ../guix-bioinformatics/gn/packages/bioinformatics.scm:215:2 #+end_src sh :lang bash + +Install with + +#+begin_src sh :lang bash +gn-stable-guix$ env GUIX_PACKAGE_PATH=../guix-bioinformatics ./pre-inst-env guix package -i genenetwork2 +#+end_src sh :lang bash + +* Create archive + +: env GUIX_PACKAGE_PATH=../../genenetwork/guix-bioinformatics/ ./pre-inst-env guix archive --export -r genenetwork2 > guix_gn2-2.0-9e9475053.nar diff --git a/doc/README.org b/doc/README.org index 375a5d20..d9730948 100644 --- a/doc/README.org +++ b/doc/README.org @@ -3,6 +3,7 @@ * Table of Contents :TOC: - [[#introduction][Introduction]] - [[#binary-deployment-wip][Binary deployment (WIP)]] + - [[#install-genenetwork-server][Install genenetwork server]] - [[#run-mysql-server][Run MySQL server]] - [[#start-the-gn2-server][Start the GN2 server]] - [[#source-deployment-and-other-information-on-reproducibility][Source deployment and other information on reproducibility]] @@ -16,7 +17,27 @@ explain the GeneNetwork deployment system which is based on GNU Guix * Binary deployment (WIP) GN can be deployed either as a binary tarball or as a GNU Guix -package. +package. First install GNU Guix following the instructions of the +[[https://www.gnu.org/software/guix/manual/html_node/Binary-Installation.html#Binary-Installation][binary installation]] using a tar ball from [[https://www.gnu.org/software/guix/download/][here]] and, update guix with a +'guix pull' and make guix visible in the path. More information +exists also in my [[https://github.com/pjotrp/guix-notes/blob/master/INSTALL.org][guix-notes]]. + +With guix running you should be able to install python, for example. + +: guix package -i python2 + +This will make python appear in $HOME/.guix-profile/bin/python. Suggested +environment settings can be seen with + +: guix package --search-paths + +** Install genenetwork server + +Fetch the nar file and install it after adding the key with, for +example + +: cat signing-key.pub |.guix-profile/bin/guix archive --authorize +: guix archive --import < guix_gn2-2.0-9e9475053.nar ** Run MySQL server diff --git a/etc/default_settings.py b/etc/default_settings.py index 929bd687..48d3f66b 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -1,13 +1,14 @@ import os +import sys -LOGFILE = "/var/log/genenetwork/wqflask.log" +LOGFILE = "/tmp/genenetwork2.log" # This is needed because Flask turns key errors into a # 400 bad request response with no exception/log TRAP_BAD_REQUEST_ERRORS = True -DB_URI = "mysql://gn2:default@localhost/db_webqtl" -SQLALCHEMY_DATABASE_URI = 'mysql://gn2:default@localhost/db_webqtl' +DB_URI = "mysql://gn2:mysql_password@localhost/db_webqtl_s" +SQLALCHEMY_DATABASE_URI = 'mysql://gn2:mysql_password@localhost/db_webqtl_s' # http://pythonhosted.org/Flask-Security/configuration.html SECURITY_CONFIRMABLE = True @@ -22,7 +23,7 @@ SERVER_PORT = 5003 SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' # Path overrides for Genenetwork -HOME=os.environ.get('HOME') -PYLMM_PATH = HOME+"/izip/git/opensource/python/pylmm_gn2/" -PLINK_PATH = HOME+"/.guix-profile/bin" -GEMMA_PATH = HOME+"/.guix-profile/bin" +GENENETWORK_FILES = "../../gn2_data" +PYLMM_RUN = os.popen("which pylmm_redis").read() +PLINK_RUN = os.popen("which plink2").read() +GEMMA_RUN = os.popen("which gemma").read() diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index e37a838f..0e5a3ac1 100755 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -405,10 +405,11 @@ class DatasetGroup(object): #print("Cache not hit") from utility.tools import plink_command - PLINK_PATH,PLINK_COMMAND = plink_command() + PLINK_RUN = plink_command() geno_file_path = webqtlConfig.GENODIR+self.name+".geno" plink_file_path = PLINK_PATH+"/"+self.name+".fam" + # @FIXME PJOTR/ZACH: .fam files should go into FLATFILES if os.path.isfile(plink_file_path): self.samplelist = get_group_samplelists.get_samplelist("plink", plink_file_path) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 0db195df..c3c9b292 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -9,22 +9,22 @@ import os import sys from wqflask import app -def get_setting(id,default,guess,find_path): +def get_setting(command_id,guess=None): """Resolve a setting from the environment or the global settings in app.config, with get_valid_path is a function checking whether the - path points to an expected directory an returns the full path e.g. + path points to an expected directory and returns the full path to + the binary command guess = os.environ.get('HOME')+'/pylmm' - get_setting('PYLMM_PATH',default,guess,get_valid_path) + get_setting('PYLMM_PATH',guess) first tries the environment variable in +id+, next gets the Flask - app setting for the same +id+, next tries the path passed in with - +default+ and finally does an educated +guess+. + app setting for the same +id+ and finally does an educated + +guess+. In all, the environment overrides the others, next is the flask - setting, then the default and finally the guess (which is - $HOME/repo). A valid path is returned. If none is resolved an - exception is thrown. + setting, then the guess. A valid path to the binary command is + returned. If none is resolved an exception is thrown. Note that we do not use the system path. This is on purpose because it will mess up controlled (reproducible) deployment. The @@ -33,46 +33,36 @@ def get_setting(id,default,guess,find_path): different settings.py file (or setting the environment). """ - # ---- Check whether environment exists - path = find_path(os.environ.get(id)) - # ---- Check whether setting exists - setting = app.config.get(id) - if not path: - path = find_path(setting) - # ---- Check whether default exists - if not path: - path = find_path(default) - # ---- Guess directory - if not path: - guess = os.environ.get('HOME')+guess - if not setting: - setting = guess - path = find_path(guess) - if not path: - raise Exception(id+' '+setting+' path unknown or faulty (update settings.py?). '+id+' should point to the path') - return path - -def find_command(command,id1,default,guess): - def find_path(path): - """Test for a valid repository""" - if path: - sys.stderr.write("Trying "+id1+" in "+path+"\n") - binary = str.split(command)[0] - if path and os.path.isfile(path+'/'+binary): - return path + def valid(command): + if command: + sys.stderr.write("Found value "+command+"\n") + return command else: - None + return None + + # ---- Check whether environment exists + sys.stderr.write("Looking for "+command_id+"\n") + command = valid(os.environ.get(command_id)) + if not command: + # ---- Check whether setting exists in app + command = valid(app.config.get(command_id)) + if not command: + command = valid(guess) + if not command: + raise Exception(command_id+' path unknown or faulty (update settings.py?). '+command_id+' should point to the path') + return command - path = get_setting(id1,default,guess,find_path) - binary = path+'/'+command - sys.stderr.write("Found "+binary+"\n") - return path,binary +def pylmm_command(guess=None): + return get_setting("PYLMM_RUN",guess) -def pylmm_command(default=None): - return find_command('pylmm_gn2/lmm.py',"PYLMM_PATH",default,'/pylmm2') +def gemma_command(guess=None): + return get_setting("GEMMA_RUN",guess) -def gemma_command(default=None): - return find_command('gemma',"GEMMA_PATH",default,'/gemma') +def plink_command(guess=None): + return get_setting("PLINK_RUN",guess) -def plink_command(default=None): - return find_command('plink2',"PLINK_PATH",default,'/plink') +def flat_files(subdir=None): + base = get_setting("GENENETWORK_FILES") + if subdir: + return base+"/"+subdir + return base diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py index 159c5d6c..2f544d44 100755 --- a/wqflask/wqflask/database.py +++ b/wqflask/wqflask/database.py @@ -24,8 +24,9 @@ def init_db(): # you will have to import them first before calling init_db() #import yourapplication.models import wqflask.model - print("Creating all..") + print("database.py: Creating all model metadata..") Base.metadata.create_all(bind=engine) - print("Done creating all...") + print("database.py: Done creating all model metadata...") + print("Point your browser at http://localhost:5003/") init_db() diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index a657510d..b0f5ed69 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -46,9 +46,9 @@ from wqflask.marker_regression import gemma_mapping # runs at startup, so a missing binary will balk before running the # service -GEMMA_PATH,GEMMA_COMMAND = gemma_command() -PYLMM_PATH,PYLMM_COMMAND = pylmm_command() -PLINK_PATH,PLINK_COMMAND = plink_command() +GEMMA_RUN = gemma_command() +PYLMM_RUN = pylmm_command() +PLINK_RUN = plink_command() # RQTL_PATH,RQTL_COMMAND = rqtl_command() diff --git a/wqflask/wqflask/show_trait/show_trait.py b/wqflask/wqflask/show_trait/show_trait.py index 2d4c952a..458e48da 100755 --- a/wqflask/wqflask/show_trait/show_trait.py +++ b/wqflask/wqflask/show_trait/show_trait.py @@ -16,7 +16,8 @@ from base import webqtlConfig from base import webqtlCaseData from wqflask.show_trait.SampleList import SampleList from utility import webqtlUtil, Plot, Bunch, helper_functions -from utility.tools import pylmm_command, plink_command +# from utility.tools import plink_command +from utility.tools import flat_files from base.trait import GeneralTrait from base import data_set from dbFunction import webqtlDatabaseFunction @@ -24,8 +25,7 @@ from basicStatistics import BasicStatisticsFunctions from pprint import pformat as pf -PYLMM_PATH,PYLMM_COMMAND = pylmm_command() -PLINK_PATH,PLINK_COMMAND = plink_command() +MAPPING_FILES = flat_files("mapping") ############################################### # @@ -162,8 +162,8 @@ class ShowTrait(object): def get_mapping_methods(self): '''Only display mapping methods when the dataset group's genotype file exists''' def check_plink_gemma(): - if (os.path.isfile(PLINK_PATH+"/"+self.dataset.group.name+".bed") and - os.path.isfile(PLINK_PATH+"/"+self.dataset.group.name+".map")): + if (os.path.isfile(MAPPYING_FILES+"/"+self.dataset.group.name+".bed") and + os.path.isfile(MAPPING_FILES+"/"+self.dataset.group.name+".map")): return True else: return False -- cgit v1.2.3 From 92fda7557645199276bf4f8a65c40252c4d83c21 Mon Sep 17 00:00:00 2001 From: pjotrp Date: Wed, 24 Feb 2016 09:25:43 +0000 Subject: Settled on the _COMMAND syntax over _RUN --- etc/default_settings.py | 6 +++--- wqflask/utility/tools.py | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'etc/default_settings.py') diff --git a/etc/default_settings.py b/etc/default_settings.py index 48d3f66b..6a218f26 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -24,6 +24,6 @@ SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a # Path overrides for Genenetwork GENENETWORK_FILES = "../../gn2_data" -PYLMM_RUN = os.popen("which pylmm_redis").read() -PLINK_RUN = os.popen("which plink2").read() -GEMMA_RUN = os.popen("which gemma").read() +PYLMM_COMMAND = os.popen("which pylmm_redis").read() +PLINK_COMMAND = os.popen("which plink2").read() +GEMMA_COMMAND = os.popen("which gemma").read() diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index d4c10c68..0f2e4d88 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -1,9 +1,5 @@ # Tools/paths finder resolves external paths from settings and/or environment # variables -# -# Currently supported: -# -# PYLMM_PATH finds the root of the git repository of the pylmm_gn2 tool import os import sys @@ -69,13 +65,13 @@ def valid_path(dir): return None def pylmm_command(guess=None): - return valid_bin(get_setting("PYLMM_RUN",guess)) + return valid_bin(get_setting("PYLMM_COMMAND",guess)) def gemma_command(guess=None): - return valid_bin(get_setting("GEMMA_RUN",guess)) + return valid_bin(get_setting("GEMMA_COMMAND",guess)) def plink_command(guess=None): - return valid_bin(get_setting("PLINK_RUN",guess)) + return valid_bin(get_setting("PLINK_COMMAND",guess)) def flat_files(subdir=None): base = get_setting("GENENETWORK_FILES") -- cgit v1.2.3 From 575e00b1061c58952cba38af5ab078ca0081b4d7 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 24 Feb 2016 16:34:52 +0000 Subject: [PATCH 041/100] Fixes for running tools --- etc/default_settings.py | 6 +++--- wqflask/utility/tools.py | 4 ++-- wqflask/wqflask/marker_regression/marker_regression.py | 3 +-- wqflask/wqflask/marker_regression/marker_regression_gn1.py | 7 ++++--- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'etc/default_settings.py') diff --git a/etc/default_settings.py b/etc/default_settings.py index 6a218f26..60a3a7b4 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -24,6 +24,6 @@ SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a # Path overrides for Genenetwork GENENETWORK_FILES = "../../gn2_data" -PYLMM_COMMAND = os.popen("which pylmm_redis").read() -PLINK_COMMAND = os.popen("which plink2").read() -GEMMA_COMMAND = os.popen("which gemma").read() +PYLMM_COMMAND = str.strip(os.popen("which pylmm_redis").read()) +PLINK_COMMAND = str.strip(os.popen("which plink2").read()) +GEMMA_COMMAND = str.strip(os.popen("which gemma").read()) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index 67c5128a..51189fa3 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -133,7 +133,7 @@ def tempdir(): # Cached values PYLMM_COMMAND = pylmm_command() -GEMMA_COMMAND = pylmm_command() -PLINK_COMMAND = pylmm_command() +GEMMA_COMMAND = gemma_command() +PLINK_COMMAND = plink_command() FLAT_FILES = flat_files() TEMPDIR = tempdir() diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 265f9473..910d0c3c 100644 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -937,8 +937,7 @@ class MarkerRegression(object): Redis.expire(key, 60*60) print("before printing command") - command = PYLMM_COMMAND + ' --key {} --species {}'.format(key, - "other") + command = PYLMM_COMMAND + ' --key {} --species {}'.format(key, "other") print("command is:", command) print("after printing command") diff --git a/wqflask/wqflask/marker_regression/marker_regression_gn1.py b/wqflask/wqflask/marker_regression/marker_regression_gn1.py index decde579..4edc1891 100644 --- a/wqflask/wqflask/marker_regression/marker_regression_gn1.py +++ b/wqflask/wqflask/marker_regression/marker_regression_gn1.py @@ -28,6 +28,7 @@ import time import string from math import * import piddle as pid +import piddlePIL as pil import sys,os import cPickle import httplib, urllib @@ -551,7 +552,7 @@ class MarkerRegression(object): # showLocusForm = webqtlUtil.genRandStr("fm_") #else: showLocusForm = "" - intCanvas = pid.PILCanvas(size=(self.graphWidth, self.graphHeight)) + intCanvas = pil.PILCanvas(size=(self.graphWidth, self.graphHeight)) gifmap = self.plotIntMapping(intCanvas, startMb = self.startMb, endMb = self.endMb, showLocusForm= showLocusForm) self.gifmap = gifmap.__str__() @@ -563,7 +564,7 @@ class MarkerRegression(object): #Scales plot differently for high resolution if self.draw2X: - intCanvasX2 = pid.PILCanvas(size=(self.graphWidth*2,self.graphHeight*2)) + intCanvasX2 = pil.PILCanvas(size=(self.graphWidth*2,self.graphHeight*2)) gifmapX2 = self.plotIntMapping(intCanvasX2, startMb = self.startMb, endMb = self.endMb, showLocusForm= showLocusForm, zoom=2) intCanvasX2.save(os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename+"X2"), format='png') #DLintImgX2=HT.Href(text='Download',url = '/image/'+self.filename+'X2.png', Class='smallsize', target='_blank') @@ -2582,7 +2583,7 @@ class MarkerRegression(object): ######################################### # Permutation Graph ######################################### - myCanvas = pid.PILCanvas(size=(400,300)) + myCanvas = pil.PILCanvas(size=(400,300)) if 'lod_score' in self.qtlresults[0] and self.LRS_LOD == "LRS": perm_output = [value*4.16 for value in self.perm_output] elif 'lod_score' not in self.qtlresults[0] and self.LRS_LOD == "LOD": -- cgit v1.2.3 From a66858e99c2195d90a187899db6f4dd8966a0a2c Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 3 Mar 2016 11:21:01 +0000 Subject: Show error when GENODIR is missing --- bin/genenetwork2 | 13 +++++++------ etc/default_settings.py | 2 +- wqflask/utility/tools.py | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'etc/default_settings.py') diff --git a/bin/genenetwork2 b/bin/genenetwork2 index a0a013fc..bbb2a19f 100755 --- a/bin/genenetwork2 +++ b/bin/genenetwork2 @@ -9,18 +9,19 @@ 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 + GN2_BASE_PATH=$GN2_GUIX_PATH +fi echo $GN2_BASE_PATH # Handle settings parameter settings=$1 if [ -z $settings ]; then settings=$GN2_BASE_PATH/etc/default_settings.py ; fi if [ ! -e $settings ]; then - GN2_BASE_PATH=$GN2_BASE_PATH/lib/python2.7/site-packages/genenetwork2-2.0-py2.7.egg - settings=$GN2_BASE_PATH/etc/default_settings.py - if [ ! -e $settings ]; then - echo "ERROR: can not locate settings file - pass it in the command line" - exit 1 - fi + echo "ERROR: can not locate settings file - pass it in the command line" + exit 1 fi export WQFLASK_SETTINGS=$settings diff --git a/etc/default_settings.py b/etc/default_settings.py index 60a3a7b4..0cf40265 100644 --- a/etc/default_settings.py +++ b/etc/default_settings.py @@ -23,7 +23,7 @@ SERVER_PORT = 5003 SECRET_HMAC_CODE = '\x08\xdf\xfa\x93N\x80\xd9\\H@\\\x9f`\x98d^\xb4a;\xc6OM\x946a\xbc\xfc\x80:*\xebc' # Path overrides for Genenetwork -GENENETWORK_FILES = "../../gn2_data" +GENENETWORK_FILES = os.environ['HOME']+"/gn2_data" PYLMM_COMMAND = str.strip(os.popen("which pylmm_redis").read()) PLINK_COMMAND = str.strip(os.popen("which plink2").read()) GEMMA_COMMAND = str.strip(os.popen("which gemma").read()) diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py index b8eff12a..9405a9c6 100644 --- a/wqflask/utility/tools.py +++ b/wqflask/utility/tools.py @@ -76,8 +76,8 @@ def plink_command(guess=None): def flat_files(subdir=None): base = get_setting("GENENETWORK_FILES") if subdir: - return valid_path(base+"/"+subdir) - return valid_path(base) + return assert_dir(base+"/"+subdir) + return assert_dir(base) def assert_dir(dir): if not valid_path(dir): -- cgit v1.2.3