aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rwxr-xr-xwqflask/runserver.py6
-rwxr-xr-xwqflask/wqflask/marker_regression/marker_regression.py14
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/gn2.py30
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm.py19
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/lmm2.py18
5 files changed, 56 insertions, 31 deletions
diff --git a/wqflask/runserver.py b/wqflask/runserver.py
index 9d5686a9..fadae6bf 100755
--- a/wqflask/runserver.py
+++ b/wqflask/runserver.py
@@ -20,9 +20,9 @@ from wqflask import app
import logging
#from themodule import TheHandlerYouWant
-file_handler = logging.FileHandler("/tmp/flask_gn_log_danny_unsecure")
-file_handler.setLevel(logging.DEBUG)
-app.logger.addHandler(file_handler)
+# file_handler = logging.FileHandler("/tmp/flask_gn_log_danny_unsecure")
+# file_handler.setLevel(logging.DEBUG)
+# app.logger.addHandler(file_handler)
import logging_tree
logging_tree.printout()
diff --git a/wqflask/wqflask/marker_regression/marker_regression.py b/wqflask/wqflask/marker_regression/marker_regression.py
index 7708356b..ae3e062f 100755
--- a/wqflask/wqflask/marker_regression/marker_regression.py
+++ b/wqflask/wqflask/marker_regression/marker_regression.py
@@ -40,6 +40,7 @@ from utility import temp_data
from utility.benchmark import Bench
+PYLMM_COMMAND= 'python /home/pjotr/izip/git/opensource/python/gn2/wqflask/wqflask/my_pylmm/pyLMM/lmm.py'
class MarkerRegression(object):
@@ -272,7 +273,7 @@ class MarkerRegression(object):
""")
def run_rqtl_geno(self):
- print("Calling R/qtl from python")
+ print("Calling R/qtl")
self.geno_to_rqtl_function()
@@ -655,8 +656,7 @@ class MarkerRegression(object):
Redis.set(key, json_params)
Redis.expire(key, 60*60)
- command = 'python /home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/lmm.py --key {} --species {}'.format(key,
- "other")
+ command = PYLMM_COMMAND+' --key {} --species {}'.format(key,"other")
os.system(command)
@@ -713,8 +713,8 @@ class MarkerRegression(object):
# "refit": False,
# "temp_data": tempdata}
- print("genotype_matrix:", str(genotype_matrix.tolist()))
- print("pheno_vector:", str(pheno_vector.tolist()))
+ # print("genotype_matrix:", str(genotype_matrix.tolist()))
+ # print("pheno_vector:", str(pheno_vector.tolist()))
params = dict(pheno_vector = pheno_vector.tolist(),
genotype_matrix = genotype_matrix.tolist(),
@@ -732,7 +732,7 @@ class MarkerRegression(object):
Redis.expire(key, 60*60)
print("before printing command")
- command = 'python /home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/lmm.py --key {} --species {}'.format(key,
+ command = PYLMM_COMMAND + ' --key {} --species {}'.format(key,
"other")
print("command is:", command)
print("after printing command")
@@ -806,7 +806,7 @@ class MarkerRegression(object):
print("Before creating the command")
- command = 'python /home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/lmm.py --key {} --species {}'.format(key,
+ command = PYLMM_COMMAND+' --key {} --species {}'.format(key,
"human")
print("command is:", command)
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/gn2.py b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py
index 7bceb089..b128bfab 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/gn2.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/gn2.py
@@ -1,7 +1,10 @@
-# Genenetwork2 specific methods and callback handler
+# Standalone specific methods and callback handler
#
# Copyright (C) 2015 Pjotr Prins (pjotr.prins@thebird.nl)
#
+# Set the log level with
+#
+# logging.basicConfig(level=logging.DEBUG)
from __future__ import absolute_import, print_function, division
@@ -9,10 +12,12 @@ import numpy as np
import sys
import logging
-# logging.basicConfig(level=logging.DEBUG)
-# np.set_printoptions()
+# logger = logging.getLogger(__name__)
+logger = logging.getLogger('lmm2')
+logging.basicConfig(level=logging.DEBUG)
+np.set_printoptions(precision=3,suppress=True)
-progress_location = None
+progress_location = None
progress_current = None
progress_prev_perc = None
@@ -20,30 +25,37 @@ def progress_default_func(location,count,total):
global progress_current
value = round(count*100.0/total)
progress_current = value
-
+
progress_func = progress_default_func
def progress_set_func(func):
global progress_func
progress_func = func
-
+
def progress(location, count, total):
global progress_location
global progress_prev_perc
-
+
perc = round(count*100.0/total)
if perc != progress_prev_perc and (location != progress_location or perc > 98 or perc > progress_prev_perc + 5):
progress_func(location, count, total)
logger.info("Progress: %s %d%%" % (location,perc))
progress_location = location
progress_prev_perc = perc
-
+
def mprint(msg,data):
"""
Array/matrix print function
"""
m = np.array(data)
- print(msg,m.shape,"=\n",m)
+ if m.ndim == 1:
+ print(msg,m.shape,"=\n",m[0:3]," ... ",m[-3:])
+ if m.ndim == 2:
+ print(msg,m.shape,"=\n[",
+ m[0][0:3]," ... ",m[0][-3:],"\n ",
+ m[1][0:3]," ... ",m[1][-3:],"\n ...\n ",
+ m[-2][0:3]," ... ",m[-2][-3:],"\n ",
+ m[-1][0:3]," ... ",m[-1][-3:],"]")
def fatal(msg):
logger.critical(msg)
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
index b2067b27..6fff5f1d 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm.py
@@ -42,25 +42,27 @@ from redis import Redis
Redis = Redis()
import sys
-sys.path.append("/home/zas1024/gene/wqflask/")
-
-has_gn2=True
from utility.benchmark import Bench
from utility import temp_data
-sys.path.append("/home/zas1024/gene/wqflask/wqflask/my_pylmm/pyLMM/")
-
from kinship import kinship, kinship_full, kvakve
import genotype
import phenotype
import gwas
+has_gn2=True
+sys.stderr.write("INFO: pylmm system path is "+":".join(sys.path)+"\n")
+sys.stderr.write("INFO: pylmm file is "+__file__+"\n")
+
# ---- A trick to decide on the environment:
try:
- from wqflask.my_pylmm.pyLMM import chunks
+ sys.stderr.write("INFO: trying loading module\n")
+ import utility.formatting # this is never used, just to check the environment
+ sys.stderr.write("INFO: This is a genenetwork2 environment\n")
from gn2 import uses, progress_set_func
except ImportError:
+ # Failed to load gn2
has_gn2=False
import standalone as handlers
from standalone import uses, progress_set_func
@@ -856,7 +858,8 @@ def gwas_with_redis(key,species,new_code=True):
print(key)
v = params[key]
if v is not None:
- v = np.array(v)
+ v = np.array(v).astype(np.float)
+ print(v)
return v
def narrayT(key):
@@ -969,6 +972,6 @@ if __name__ == '__main__':
if has_gn2:
gn2_main()
else:
- print("Run from runlmm.py instead")
+ fatal("Run from runlmm.py instead")
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/lmm2.py b/wqflask/wqflask/my_pylmm/pyLMM/lmm2.py
index 358bf27e..c65843ec 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/lmm2.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/lmm2.py
@@ -24,14 +24,24 @@ from scipy import optimize
from optmatrix import matrixMult
import kinship
+sys.stderr.write("INFO: pylmm (lmm2) system path is "+":".join(sys.path)+"\n")
+sys.stderr.write("INFO: pylmm (lmm2) file is "+__file__+"\n")
+
# ---- A trick to decide on the environment:
try:
- from wqflask.my_pylmm.pyLMM import chunks
- from gn2 import uses
+ sys.stderr.write("INFO: trying loading module\n")
+ import utility.formatting # this is never used, just to check the environment
+ sys.stderr.write("INFO: This is a genenetwork2 environment (lmm2)\n")
+ from gn2 import uses, progress_set_func
except ImportError:
- sys.stderr.write("WARNING: LMM2 standalone version missing the Genenetwork2 environment\n")
+ # Failed to load gn2
has_gn2=False
- from standalone import uses
+ import standalone as handlers
+ from standalone import uses, progress_set_func
+ sys.stderr.write("WARNING: LMM2 standalone version missing the Genenetwork2 environment\n")
+
+progress,mprint,debug,info,fatal = uses('progress','mprint','debug','info','fatal')
+
def calculateKinship(W,center=False):
"""