From 27ed6ba528a162dfa5c3178348c99917c74d35f6 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 16 Oct 2013 12:43:47 -0400 Subject: frequency_per_sequence still needs refactoring --- kmer_frequency_per_sequence.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'kmer_frequency_per_sequence.c') diff --git a/kmer_frequency_per_sequence.c b/kmer_frequency_per_sequence.c index f2aa112..d3e21a1 100644 --- a/kmer_frequency_per_sequence.c +++ b/kmer_frequency_per_sequence.c @@ -7,19 +7,6 @@ #include "kmer_utils.h" unsigned long position = 0; - -const unsigned char alpha[256] = -{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 1, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 1, 5, 5, 5, 2, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}; - int main(int argc, char **argv) { char *line = NULL; @@ -40,13 +27,18 @@ int main(int argc, char **argv) { const unsigned long width = (unsigned long)1 << (kmer * 2); + unsigned long long *counts = malloc((width+ 1) * sizeof(unsigned long long)); + if(counts == NULL) + exit(EXIT_FAILURE); + while ((read = getline(&line, &len, fh)) != -1) { if(line[0] != '>' && (read > kmer)) { unsigned int i = 0; - unsigned long long *counts = malloc((width+ 1) * sizeof(unsigned long long)); - if(counts == NULL) - exit(EXIT_FAILURE); + unsigned long total = 0; + + // reset our count matrix to zero + memset(counts, 0, width); for(i = 0; i < read - kmer; i++) { line[i] = alpha[line[i]]; @@ -56,7 +48,6 @@ int main(int argc, char **argv) { counts[num_to_index(&line[i],kmer, width)]++; } - unsigned long total = 0; for(i = 0; i < width; i++) total += counts[i]; -- cgit v1.2.1