aboutsummaryrefslogtreecommitdiff
path: root/kmer_frequency_per_sequence.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-10-04 18:25:21 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2013-10-04 18:25:21 -0400
commit2a831c405c8372f86c22c5cf3684f63209877b49 (patch)
treec6389ac7755a85d44cafe22d4266b0edad7bedb4 /kmer_frequency_per_sequence.c
parent90106ba794458787db91b8c85f5f8740831f14bd (diff)
no more branching
Diffstat (limited to 'kmer_frequency_per_sequence.c')
-rw-r--r--kmer_frequency_per_sequence.c20
1 files changed, 17 insertions, 3 deletions
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)]++;