diff options
-rw-r--r-- | wqflask/utility/tools.py | 37 | ||||
-rwxr-xr-x | wqflask/wqflask/marker_regression/marker_regression.py | 14 |
2 files changed, 39 insertions, 12 deletions
diff --git a/wqflask/utility/tools.py b/wqflask/utility/tools.py new file mode 100644 index 00000000..3c972557 --- /dev/null +++ b/wqflask/utility/tools.py @@ -0,0 +1,37 @@ +# 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 + +def get_setting(): + """ + Resolve a setting from the environment or the global settings in app.config + """ + pass + +def pylmm_command(default=None): + def get_valid_path(path): + if path and os.path.isfile(path+'/lmm.py'): + return path + else: + None + + # ---- Check whether environment exists + path = get_valid_path(os.environ['PYLMM_PATH']) + # ---- Check whether setting exists + if not path: + path = get_valid_path(app.config.get('PYLMM_PATH')) + # ---- Check whether default exists + if not path: + path = get_valid_path(default) + home = get_valid_path(os.environ['HOME']+'/pylmm_gn2') + if not path: + path = get_valid_path(home) + if not path: + raise Exception('PYLMM_PATH '+home+' unknown or faulty (add PYLMM_PATH to settings.py)') + pylmm_command = 'python '+path+'/lmm.py' + return path,pylmm_command diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py index 999a32b8..b210173b 100755 --- a/wqflask/wqflask/marker_regression/marker_regression.py +++ b/wqflask/wqflask/marker_regression/marker_regression.py @@ -36,23 +36,13 @@ from utility import webqtlUtil #from wqflask.marker_regression import plink_mapping from wqflask.marker_regression import gemma_mapping #from wqflask.marker_regression import rqtl_mapping -from wqflask.my_pylmm.data import prep_data -# from wqflask.my_pylmm.pyLMM import lmm -# from wqflask.my_pylmm.pyLMM import input from utility import helper_functions from utility import Plot, Bunch from utility import temp_data - from utility.benchmark import Bench +from utility.tools import pylmm_command -import os -if os.environ.get('PYLMM_PATH') is None: - PYLMM_PATH=app.config.get('PYLMM_PATH') - if PYLMM_PATH is None: - PYLMM_PATH=os.environ['HOME']+'/gene/wqflask/wqflask/my_pylmm/pyLMM' -if not os.path.isfile(PYLMM_PATH+'/lmm.py'): - raise Exception('PYLMM_PATH '+PYLMM_PATH+' unknown or faulty') -PYLMM_COMMAND= 'python '+PYLMM_PATH+'/lmm.py' +PYLMM_PATH,PYLMM_COMMAND = pylmm_command() class MarkerRegression(object): |