From b9d8057c2017ade6dd6ce54c45d718beb7c25c6a Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Thu, 5 Mar 2015 17:27:36 +0300 Subject: Kinship file format support (reader and writer) --- wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py | 1 - wqflask/wqflask/my_pylmm/pyLMM/runlmm.py | 49 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py b/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py index 35fccef4..012e96b2 100644 --- a/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py +++ b/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py @@ -23,7 +23,6 @@ import numpy as np # from lmm import LMM, run_other import input - usage = """ python convertlmm.py [--kinship] infile diff --git a/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py b/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py index df86f718..4a640d6d 100644 --- a/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py +++ b/wqflask/wqflask/my_pylmm/pyLMM/runlmm.py @@ -17,4 +17,53 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from optparse import OptionParser +import sys +import os +import numpy as np +# from lmm import LMM, run_other +import csv + +usage = """ +python runlmm.py [options] command + + runlmm.py processing multiplexer reads standard input types and calls the routines + + Current commands are: + + parse : only parse input files + + try --help for more information +""" + +parser = OptionParser(usage=usage) +# parser.add_option("-f", "--file", dest="input file", +# help="In", metavar="FILE") +parser.add_option("--kinship",dest="kinship", + help="Kinship file format") +parser.add_option("-q", "--quiet", + action="store_false", dest="verbose", default=True, + help="don't print status messages to stdout") + +(options, args) = parser.parse_args() + +if len(args) != 1: + print usage + sys.exit(1) + +cmd = args[0] +print "Command: ",cmd + +if options.kinship: + K1 = [] + print options.kinship + with open(options.kinship,'r') as tsvin: + assert(tsvin.readline().strip() == "# Kinship format version 1.0") + tsvin.readline() + tsvin.readline() + tsv = csv.reader(tsvin, delimiter='\t') + for row in tsv: + ns = np.genfromtxt(row[1:]) + K1.append(ns) # <--- slow + K = np.array(K1) -- cgit v1.2.3