aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorPjotr Prins2015-03-10 12:05:50 +0300
committerPjotr Prins2015-03-10 12:05:50 +0300
commit926225cf75991142e82d95b2505c59446fa1a8c4 (patch)
treea07f6d77358898ed9dd13fae2dd65ce3b3b2ba12 /wqflask
parent7d566c7bed8887dc18c1311ee84d22a8dc520889 (diff)
downloadgenenetwork2-926225cf75991142e82d95b2505c59446fa1a8c4.tar.gz
Refactored tsvreader out
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/runlmm.py9
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/tsvreader.py21
2 files changed, 18 insertions, 12 deletions
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py b/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py
index f5ecddb9..bed2e39e 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py
@@ -57,10 +57,13 @@ cmd = args[0]
print "Command: ",cmd
if options.kinship:
- k = tsvreader.kinship()
+ k = tsvreader.kinship(options.kinship)
+ print len(k)
if options.pheno:
- y = tsvreader.pheno()
+ y = tsvreader.pheno(options.pheno)
+ print len(y)
if options.geno:
- g = tsvreader.geno()
+ g = tsvreader.geno(options.geno)
+ print len(g)
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/tsvreader.py b/wqflask/wqflask/my_pylmm/pyLMM/tsvreader.py
index 7cea976e..b4027fa3 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/tsvreader.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/tsvreader.py
@@ -20,10 +20,10 @@ import os
import numpy as np
import csv
-def kinship():
+def kinship(fn):
K1 = []
- print options.kinship
- with open(options.kinship,'r') as tsvin:
+ print fn
+ with open(fn,'r') as tsvin:
assert(tsvin.readline().strip() == "# Kinship format version 1.0")
tsvin.readline()
tsvin.readline()
@@ -32,11 +32,12 @@ def kinship():
ns = np.genfromtxt(row[1:])
K1.append(ns) # <--- slow
K = np.array(K1)
+ return K
-def pheno():
+def pheno(fn):
Y1 = []
- print options.pheno
- with open(options.pheno,'r') as tsvin:
+ print fn
+ with open(fn,'r') as tsvin:
assert(tsvin.readline().strip() == "# Phenotype format version 1.0")
tsvin.readline()
tsvin.readline()
@@ -46,14 +47,15 @@ def pheno():
ns = np.genfromtxt(row[1:])
Y1.append(ns) # <--- slow
Y = np.array(Y1)
+ return Y
-def geno():
+def geno(fn):
G1 = []
hab_mapper = {'A':0,'H':1,'B':2,'-':3}
pylmm_mapper = [ 0.0, 0.5, 1.0, float('nan') ]
- print options.geno
- with open(options.geno,'r') as tsvin:
+ print fn
+ with open(fn,'r') as tsvin:
assert(tsvin.readline().strip() == "# Genotype format version 1.0")
tsvin.readline()
tsvin.readline()
@@ -70,4 +72,5 @@ def geno():
# ns = np.genfromtxt(row[1:])
G1.append(gs2) # <--- slow
G = np.array(G1)
+ return G