aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2015-03-05 16:50:14 +0300
committerPjotr Prins2015-03-05 16:50:14 +0300
commit0754dbf77f4362beaef45b0ac651676d47659b70 (patch)
tree1beb80d154274d036acdbad1f8f8df843d882eb8
parent8053869aa61fb430b89a32b0f8024fc133cea28f (diff)
downloadgenenetwork2-0754dbf77f4362beaef45b0ac651676d47659b70.tar.gz
Convert textual kinship file
-rw-r--r--wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py b/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py
index 4147d90b..35fccef4 100644
--- a/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py
+++ b/wqflask/wqflask/my_pylmm/pyLMM/convertlmm.py
@@ -17,15 +17,25 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from optparse import OptionParser
+import sys
+import os
+import numpy as np
+# from lmm import LMM, run_other
+import input
+
usage = """
-Convert files for runlmm.py processing
+python convertlmm.py [--kinship] infile
+
+ Convert files for runlmm.py processing. Writes to stdout.
+
+ 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",
+parser.add_option("--kinship",action="store_false", dest="kinship", default=True,
help="Parse a kinship file. This is an nxn plain text file and can be computed with the pylmmKinship program.")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
@@ -33,4 +43,25 @@ parser.add_option("-q", "--quiet",
(options, args) = parser.parse_args()
+if len(args) == 0:
+ print usage
+ sys.exit(1)
+if options.kinship:
+ is_header = True
+ assert(len(args)==1)
+ count = 0
+ for line in open(args[0],'r'):
+ count += 1
+ if is_header:
+ size = len(line.split())
+ print "# Kinship format version 1.0"
+ print "# Size=",size
+ for i in range(size):
+ sys.stdout.write("\t"+str(i+1))
+ sys.stdout.write("\n")
+ is_header = False
+ sys.stdout.write(str(count))
+ sys.stdout.write("\t")
+ sys.stdout.write("\t".join(line.split()))
+ sys.stdout.write("\n")