From 2a831c405c8372f86c22c5cf3684f63209877b49 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Fri, 4 Oct 2013 18:25:21 -0400 Subject: no more branching --- kmer_frequency_per_sequence.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'kmer_frequency_per_sequence.c') diff --git a/kmer_frequency_per_sequence.c b/kmer_frequency_per_sequence.c index aa18dd6..02a221b 100644 --- a/kmer_frequency_per_sequence.c +++ b/kmer_frequency_per_sequence.c @@ -7,7 +7,19 @@ #include "kmer_utils.h" -long position = 0; +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) { @@ -31,14 +43,16 @@ int main(int argc, char **argv) { width = (int)pow(4, kmer); while ((read = getline(&line, &len, fh)) != -1) { - if(line[0] != '>' && read > kmer) { + 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); - convert_kmer_to_num(line, read); + for(i = 0; i < read - kmer; i++) { + line[i] = alpha[line[i]]; + } for(i = 0; i < read - kmer; i++) { counts[num_to_index(&line[i],kmer, width)]++; -- cgit v1.2.3