summaryrefslogtreecommitdiff
path: root/src/python/quikr.py
diff options
context:
space:
mode:
authorCalvin <calvin@EESI>2013-05-14 19:50:28 -0400
committerCalvin <calvin@EESI>2013-05-14 19:50:28 -0400
commit3631a0c9d47d8ff72085bcc534bd24bfad4f73da (patch)
treea259116534e6b5522d065e7dd46a414d54d57075 /src/python/quikr.py
parent7ab43937c81ad5af1b7d6b5b1d3c317b58881e84 (diff)
use sensing matrix
Diffstat (limited to 'src/python/quikr.py')
-rwxr-xr-xsrc/python/quikr.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/python/quikr.py b/src/python/quikr.py
index 98cc953..3c2b23a 100755
--- a/src/python/quikr.py
+++ b/src/python/quikr.py
@@ -39,7 +39,7 @@ def is_compressed(filename):
def train_matrix(input_file_location, kmer):
"""
- Takes a input fasta file, and kmer, returns a custom trained matrix
+ Takes a input fasta file, and kmer, returns a custom sensing matrix
"""
input_file = Popen(["bash", "-c", "probabilities-by-read " + str(kmer) + " " + input_file_location + " <(generate_kmers 6)"], stdout=PIPE)
@@ -54,23 +54,23 @@ def train_matrix(input_file_location, kmer):
return matrix
-def load_trained_matrix_from_file(trained_matrix_location):
- """ This is a helper function to load our trained matrix and run quikr """
+def load_sensing_matrix_from_file(sensing_matrix_location):
+ """ This is a helper function to load our sensing matrix and run quikr """
- if is_compressed(trained_matrix_location):
- trained_matrix_file = gzip.open(trained_matrix_location, "rb")
+ if is_compressed(sensing_matrix_location):
+ sensing_matrix_file = gzip.open(sensing_matrix_location, "rb")
else:
- trained_matrix_file = open(trained_matrix_location, "rb")
+ sensing_matrix_file = open(sensing_matrix_location, "rb")
- trained_matrix = np.load(trained_matrix_file)
+ sensing_matrix = np.load(sensing_matrix_file)
- return trained_matrix
+ return sensing_matrix
-def calculate_estimated_frequencies(input_fasta_location, trained_matrix, kmer, default_lambda):
+def calculate_estimated_frequencies(input_fasta_location, sensing_matrix, kmer, default_lambda):
"""
input_fasta is the input fasta file to find the estimated frequencies of
- trained_matrix is the trained matrix we are using to estimate the species
+ sensing_matrix is the sensing matrix we are using to estimate the species
kmer is the desired k-mer to use
default_lambda is inp
@@ -93,10 +93,10 @@ def calculate_estimated_frequencies(input_fasta_location, trained_matrix, kmer,
counts = np.concatenate([np.zeros(1), counts])
#form the k-mer sensing matrix
- trained_matrix = trained_matrix * default_lambda;
- trained_matrix = np.vstack((np.ones(trained_matrix.shape[1]), trained_matrix))
+ sensing_matrix = sensing_matrix * default_lambda;
+ sensing_matrix = np.vstack((np.ones(sensing_matrix.shape[1]), sensing_matrix))
- xstar, rnorm = scipy.optimize.nnls(trained_matrix, counts)
+ xstar, rnorm = scipy.optimize.nnls(sensing_matrix, counts)
xstar = xstar / xstar.sum(0)
return xstar