From a3fa9325a9b02390151eb3b0ae1e41fb0816d7fd Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Sat, 16 Mar 2013 15:16:27 -0400 Subject: we don't need a kmer file anymore :-) --- src/python/quikr.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/python/quikr.py b/src/python/quikr.py index 225ea9b..cb33493 100755 --- a/src/python/quikr.py +++ b/src/python/quikr.py @@ -56,12 +56,6 @@ def train_matrix(input_file_location, kmer): Takes a input fasta file, and kmer, returns a custom trained matrix """ - kmer_file_name = str(kmer) + "mers.txt" - - if not os.path.isfile(kmer_file_name): - print "could not find kmer file" - exit() - input_file = Popen(["bash", "-c", "probabilities-by-read " + str(kmer) + " " + input_file_location + " <(generate_kmers 6)"], stdout=PIPE) # load and normalize the matrix by dividing each element by the sum of it's column. -- cgit v1.2.3 From bb810d85d92648d5cc812891dc8ca90b5fe4aa7a Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Sat, 16 Mar 2013 15:28:32 -0400 Subject: use is_compressed --- src/python/quikr.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python/quikr.py b/src/python/quikr.py index cb33493..a756e6c 100755 --- a/src/python/quikr.py +++ b/src/python/quikr.py @@ -23,10 +23,10 @@ def generate_kmers(kmer): return '\n'.join(''.join(x) for x in itertools.product('acgt', repeat=kmer)) -def isCompressed(filename): +def is_compressed(filename): """ This function checks to see if the file is gzipped - >>> boolean_value = isCompressed("/path/to/compressed/gzip/file") + >>> boolean_value = is_compressed("/path/to/compressed/gzip/file") >>> print boolean_value True @@ -39,7 +39,7 @@ def isCompressed(filename): try: f = open(filename, "rb") except IOError: - print "Warning: isCompressed could not find " + filename + print "Warning: is_compressed could not find " + filename return False # The first two bytes of a gzipped file are always '1f 8b' @@ -71,7 +71,7 @@ def train_matrix(input_file_location, kmer): def load_trained_matrix_from_file(trained_matrix_location): """ This is a helper function to load our trained matrix and run quikr """ - if isCompressed(trained_matrix_location): + if is_compressed(trained_matrix_location): trained_matrix_file = gzip.open(trained_matrix_location, "rb") else: trained_matrix_file = open(trained_matrix_location, "rb") -- cgit v1.2.3 From a5918b4422a4f21505f25517a0e505e1bff0e81b Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Sat, 16 Mar 2013 17:41:32 -0400 Subject: add return code checking --- src/python/quikr.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/python/quikr.py b/src/python/quikr.py index a756e6c..857cd25 100755 --- a/src/python/quikr.py +++ b/src/python/quikr.py @@ -57,6 +57,9 @@ def train_matrix(input_file_location, kmer): """ input_file = Popen(["bash", "-c", "probabilities-by-read " + str(kmer) + " " + input_file_location + " <(generate_kmers 6)"], stdout=PIPE) + input_file.poll() + if input_file.returncode != 0: + raise ValueError, "probbilties-by-read did not execute properly" # load and normalize the matrix by dividing each element by the sum of it's column. # also do some fancy rotations so that it works properly with quikr @@ -97,7 +100,11 @@ def calculate_estimated_frequencies(input_fasta_location, trained_matrix, kmer, """ # We use the count program to count + count_input = Popen(["count-kmers", "-r", str(kmer), "-1", "-u", input_fasta_location], stdout=PIPE) + count_input.poll() + if count_input.returncode != 0: + raise ValueError, "count-kmers did not execute properly" # load the output of our count program and form a probability vector from the counts counts = np.loadtxt(count_input.stdout) -- cgit v1.2.3 From e0abcffc2fba1e69dfc2bc51020dd6c013e38697 Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Mon, 18 Mar 2013 10:11:25 -0400 Subject: remove checking, seems like the sml code isn't returning sane values --- src/python/quikr.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/python/quikr.py b/src/python/quikr.py index 857cd25..1fa27c7 100755 --- a/src/python/quikr.py +++ b/src/python/quikr.py @@ -57,9 +57,6 @@ def train_matrix(input_file_location, kmer): """ input_file = Popen(["bash", "-c", "probabilities-by-read " + str(kmer) + " " + input_file_location + " <(generate_kmers 6)"], stdout=PIPE) - input_file.poll() - if input_file.returncode != 0: - raise ValueError, "probbilties-by-read did not execute properly" # load and normalize the matrix by dividing each element by the sum of it's column. # also do some fancy rotations so that it works properly with quikr @@ -102,9 +99,6 @@ def calculate_estimated_frequencies(input_fasta_location, trained_matrix, kmer, # We use the count program to count count_input = Popen(["count-kmers", "-r", str(kmer), "-1", "-u", input_fasta_location], stdout=PIPE) - count_input.poll() - if count_input.returncode != 0: - raise ValueError, "count-kmers did not execute properly" # load the output of our count program and form a probability vector from the counts counts = np.loadtxt(count_input.stdout) -- cgit v1.2.3