summaryrefslogtreecommitdiff
path: root/quikr.py
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-03-07 14:29:06 -0500
committerCalvin <calvin@EESI>2013-03-07 14:29:06 -0500
commit29a242c629a37cc6099f55b38f18b86b2df28cf4 (patch)
tree7659f4f95396e40d7842d106f635747d2b56690a /quikr.py
parent0240e880ce0f7b68553021d8a85dc1d092a8a5f9 (diff)
added gzip compression support
Diffstat (limited to 'quikr.py')
-rwxr-xr-xquikr.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/quikr.py b/quikr.py
index 478c3bf..401b5ca 100755
--- a/quikr.py
+++ b/quikr.py
@@ -4,13 +4,14 @@ import sys
import scipy.optimize.nnls
import scipy.sparse
import numpy as np
+import quikr_util as qu
from subprocess import *
import argparse
import platform
+import gzip
def main():
-
parser = argparse.ArgumentParser(description=
"Quikr returns the estimated frequencies of batcteria present when given a \
input FASTA file. \n \
@@ -44,12 +45,20 @@ def main():
lamb = args.lamb
xstar = quikr_load_trained_matrix_from_file(args.fasta, args.trained_matrix, args.kmer, lamb)
+
np.savetxt(args.output, xstar, delimiter=",", fmt="%f")
return 0
def quikr_load_trained_matrix_from_file(input_fasta_location, trained_matrix_location, kmer, default_lambda):
- trained_matrix = np.load(trained_matrix_location)
+ if qu.isCompressed(trained_matrix_location):
+ print "compressed!"
+ trained_matrix_file = gzip.open(trained_matrix_location, "rb")
+ else:
+ trained_matrix_file = open(trained_matrix_location, "rb")
+
+ trained_matrix = np.load(trained_matrix_file)
+
xstar = quikr(input_fasta_location, trained_matrix, kmer, default_lambda)
return xstar