diff options
Diffstat (limited to 'kmer_total_count.c')
-rw-r--r-- | kmer_total_count.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/kmer_total_count.c b/kmer_total_count.c index 9e92976..3679025 100644 --- a/kmer_total_count.c +++ b/kmer_total_count.c @@ -14,9 +14,12 @@ int main(int argc, char **argv) { size_t len = 0; ssize_t read; unsigned int i = 0; + unsigned int kmer = 0; + unsigned int width = 0; + unsigned long long *counts; if(argc != 3) { - printf("Please supply a filename, and only a filename\n"); + printf("Please supply a filename and a kmer\n"); exit(EXIT_FAILURE); } @@ -25,17 +28,20 @@ int main(int argc, char **argv) { fprintf(stderr, "Couldn't open: %s\n", argv[1]); exit(EXIT_FAILURE); } - - int kmer = atoi(argv[2]); - int width = (int)pow(4, kmer); - unsigned long long *counts = malloc((width+ 1) * sizeof(unsigned long long)); + // second argument is the kmer + kmer = atoi(argv[2]); + + // width is 4^kmer + width = (int)pow(4, kmer); + + // malloc our counts matrix + counts = malloc((width+ 1) * sizeof(unsigned long long)); if(counts == NULL) exit(EXIT_FAILURE); while ((read = getline(&line, &len, fh)) != -1) { if(line[0] != '>') { - for(i = 0; i < strlen(line) - kmer; i++) { counts[convert_kmer_to_index(&line[i],kmer, width)]++; } |