diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-29 13:25:27 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-29 13:25:27 -0400 |
commit | be6667e95f04bd65475d71c16d2789792c1e787e (patch) | |
tree | 9278682dd92242ac9e4f178416549b9bf34a7738 | |
parent | a6a9c32bae2aa0b620c7ea4497885f23bdf84265 (diff) |
Fix a nasty bug in kmer-counting code
Memset of course does not deal properly with the unsigned long long type
so we need to compensate by doing sizeof(unsigned long long) * width to
fix the issue
-rw-r--r-- | src/c/quikr_train.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/c/quikr_train.c b/src/c/quikr_train.c index 4d66b9d..0c4c136 100644 --- a/src/c/quikr_train.c +++ b/src/c/quikr_train.c @@ -160,7 +160,7 @@ int main(int argc, char **argv) { gzprintf(output, "%d\n", kmer); // malloc our return array - unsigned long long * counts = malloc((width+ 1) * sizeof(unsigned long long)); + unsigned long long * counts = malloc((width + 1) * sizeof(unsigned long long)); if(counts == NULL) { fprintf(stderr, strerror(errno)); exit(EXIT_FAILURE); @@ -216,7 +216,8 @@ int main(int argc, char **argv) { } // set counts to zero - memset(counts, 0, width); + memset(counts, 0, width * sizeof(counts)); + // loop through our string to process each k-mer for(position = 0; position < (seq_length - kmer + 1); position++) { unsigned long mer = 0; |