aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--kmer_frequency_per_sequence.c1
-rw-r--r--kmer_total_count.c24
3 files changed, 19 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index adabfb2..92719d7 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ all: libkmer.so kmer_total_count kmer_frequency_per_sequence
libkmer.so:
$(CC) kmer_utils.c -o libkmer.so $(CFLAGS) -shared -FPIC -DSHARED=0
kmer_total_count:
- $(CC) kmer_total_count.c kmer_utils.c -o kmer_total_count $(CFLAGS)
+ $(CC) kmer_total_count.c -o kmer_total_count $(CFLAGS)
kmer_frequency_per_sequence:
$(CC) kmer_frequency_per_sequence.c kmer_utils.c -o kmer_frequency_per_sequence $(CFLAGS)
diff --git a/kmer_frequency_per_sequence.c b/kmer_frequency_per_sequence.c
index 62b98cb..f2aa112 100644
--- a/kmer_frequency_per_sequence.c
+++ b/kmer_frequency_per_sequence.c
@@ -1,6 +1,5 @@
// Copyright 2013 Calvin Morrison
#include <errno.h>
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/kmer_total_count.c b/kmer_total_count.c
index 345bceb..795b5dc 100644
--- a/kmer_total_count.c
+++ b/kmer_total_count.c
@@ -1,14 +1,10 @@
// Copyright 2013 Calvin Morrison
#include <errno.h>
-#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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,
@@ -27,6 +23,7 @@ int main(int argc, char **argv) {
size_t len = 0;
ssize_t read;
long i = 0;
+ long posistion = 0;
if(argc != 3) {
printf("Please supply a filename and a kmer\n");
@@ -58,8 +55,23 @@ int main(int argc, char **argv) {
line[i] = alpha[line[i]];
}
- for(position = 0; position < (read - kmer); position++) {
- counts[num_to_index(&line[position],kmer, width)]++;
+ for(posistion = 0; posistion < (read - kmer); posistion++) {
+ unsigned long out = 0;
+ unsigned long multiply = 1;
+
+
+ for(i = posistion + kmer - 1; i >= posistion; i--){
+ if(line[i] >> 2) {
+ out = width;
+ posistion = i;
+ goto next;
+ }
+
+ out += line[i] * multiply;
+ multiply = multiply << 2;
+ }
+ next:
+ counts[out]++;
}
}
}