aboutsummaryrefslogtreecommitdiff
path: root/src/python/quikr
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
parent4ca6f92ceb4b2f8c504431cf56f8a6135187a61c (diff)
move python stuff to python directory
Diffstat (limited to 'src/python/quikr')
-rwxr-xr-xsrc/python/quikr48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/python/quikr b/src/python/quikr
new file mode 100755
index 0000000..bac01ca
--- /dev/null
+++ b/src/python/quikr
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+import sys
+import os
+import argparse
+import quikr
+import numpy as np
+
+def main():
+
+ parser = argparse.ArgumentParser(description=
+ "Quikr returns the estimated frequencies of batcteria present when given a \
+ input FASTA file. \n \
+ A default trained matrix will be used if none is supplied \n \
+ You must supply a kmer and default lambda if using a custom trained \
+ matrix.")
+
+ parser.add_argument("-f", "--fasta", help="fasta file", required=True)
+ parser.add_argument("-o", "--output", help="output path (csv output)", required=True)
+ parser.add_argument("-t", "--trained-matrix", help="trained matrix", required=True)
+ parser.add_argument("-l", "--lamb", type=int, help="the default lambda value is 10,000")
+ parser.add_argument("-k", "--kmer", type=int, required=True,
+ help="specifies which kmer to use, must be used with a custom trained database")
+
+
+ args = parser.parse_args()
+
+ # our default lambda is 10,000
+ lamb = 10000
+
+ # Make sure our input exist
+ if not os.path.isfile(args.fasta):
+ parser.error( "Input fasta file not found")
+
+ if not os.path.isfile(args.trained_matrix):
+ parser.error("Custom trained matrix not found")
+
+ # use alternative lambda
+ if args.lamb is not None:
+ lamb = args.lamb
+
+ trained_matrix = quikr.load_trained_matrix_from_file(args.trained_matrix)
+ xstar = quikr.calculate_estimated_frequencies(args.fasta, trained_matrix, args.kmer, lamb)
+
+ np.savetxt(args.output, xstar, delimiter=",", fmt="%f")
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main())