aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-10-16 12:43:47 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2013-10-16 12:43:47 -0400
commit27ed6ba528a162dfa5c3178348c99917c74d35f6 (patch)
tree8c4e976ad0f29526301c0e2edb285e9e28f314d8
parent1d09547b5bc38d1f2d1a5a173738e86dc2ac07f1 (diff)
frequency_per_sequence still needs refactoring
-rw-r--r--kmer_frequency_per_sequence.c25
1 files changed, 8 insertions, 17 deletions
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];