aboutsummaryrefslogtreecommitdiff
path: root/src/python/quikr_train
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-03-11 12:40:47 -0400
committerCalvin <calvin@EESI>2013-03-11 12:40:47 -0400
commit3f0c33ff93dea10b2f79c8c2101431e251b8b928 (patch)
tree46e2a43535d3aa0d768ec0841bdbe4957651ba7b /src/python/quikr_train
parent4ca6f92ceb4b2f8c504431cf56f8a6135187a61c (diff)
move python stuff to python directory
Diffstat (limited to 'src/python/quikr_train')
-rwxr-xr-xsrc/python/quikr_train53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/python/quikr_train b/src/python/quikr_train
new file mode 100755
index 0000000..bf74e12
--- /dev/null
+++ b/src/python/quikr_train
@@ -0,0 +1,53 @@
+#!/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.kmer is None:
+ kmer = 6
+ else:
+ kmer = 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())