From c18793c210ea44cef63db3568791cbad537bdb79 Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 8 Mar 2013 15:32:50 -0500 Subject: moving some stuff --- src/quikr_train | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 src/quikr_train (limited to 'src/quikr_train') diff --git a/src/quikr_train b/src/quikr_train new file mode 100755 index 0000000..6e599c9 --- /dev/null +++ b/src/quikr_train @@ -0,0 +1,48 @@ +#!/usr/bin/python +import numpy as np +import quikr +import os +import sys +import gzip +from subprocess import * +import platform +import argparse + +def main(): + """ + You can call this script independently, and will save the + trained matrix as a numpy file. + + example: python quikr-train.py -i input.fasta -k 6 -o trained_matrix.npy + + """ + parser = argparse.ArgumentParser(description= + " quikr_train returns a custom trained matrix that can be used with \ + the quikr function. \n You must supply a kmer. \n ") + + parser.add_argument("-i", "--input", help="training database of sequences (fasta format)", required=True) + parser.add_argument("-o", "--output", help="sensing matrix (text file)", required=True) + parser.add_argument("-k", "--kmer", help="kmer size (integer)", + type=int, required=False ) + parser.add_argument("-z", "--compress", help="compress output (integer)", + action='store_true', required=False) + + args = parser.parse_args() + + if not os.path.isfile(args.input): + parser.error( "Input database not found") + + # call the quikr train function, save the output with np.save + matrix = quikr.train_matrix(args.input, args.kmer) + + if args.compress: + output_file = gzip.open(args.output, "wb") + else: + output_file = open(args.output, "wb") + + np.save(output_file, matrix) + + return 0 + +if __name__ == "__main__": + sys.exit(main()) -- cgit v1.2.3