From 12fd24e056d18e9f7ee8e1e47a42e47c843c98ff Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 11 Sep 2013 09:43:33 -0400 Subject: move declarations to top, make sure to use the appropriate type --- kmer_total_count.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'kmer_total_count.c') 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)]++; } -- cgit v1.2.1