diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-02 18:01:47 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-10-02 18:01:47 -0400 |
commit | 4d4ca9135928c1b0c848954b1930df5fb7a209c6 (patch) | |
tree | 114bd44372851374686749d0d3ddc54ebca99b6e | |
parent | 196d56bea8897612d6ed1125589e68fd6da428a6 (diff) |
add check for line length. if read > kmer we are good to go
-rw-r--r-- | kmer_total_count.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kmer_total_count.c b/kmer_total_count.c index 8cc91a7..3a418ed 100644 --- a/kmer_total_count.c +++ b/kmer_total_count.c @@ -13,7 +13,7 @@ int main(int argc, char **argv) { char *line = NULL; size_t len = 0; ssize_t read; - unsigned long i = 0; + long i = 0; unsigned long long *counts; @@ -40,16 +40,16 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); while ((read = getline(&line, &len, fh)) != -1) { - if(line[0] != '>') { + if(line[0] != '>' && read > kmer) { convert_kmer_to_num(line, read); - for(i = 0; i < read - kmer; i++) { + for(i = 0; i < (read - kmer); i++) { counts[num_to_index(&line[i],kmer, width)]++; } } } - for(i = 0; i < width; i++) + for(i = 0; i < (unsigned)width; i++) printf("%llu\n", counts[i]); |