diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-09-11 09:43:33 -0400 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-09-11 09:43:33 -0400 |
commit | 12fd24e056d18e9f7ee8e1e47a42e47c843c98ff (patch) | |
tree | a359b48441b1f3cbe9561a26a9a273fd9d5c6fa4 | |
parent | f52d24cd7099fc930fca785ec65401de50cd931d (diff) |
move declarations to top, make sure to use the appropriate type
-rw-r--r-- | kmer_frequency_per_sequence.c | 5 | ||||
-rw-r--r-- | kmer_total_count.c | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/kmer_frequency_per_sequence.c b/kmer_frequency_per_sequence.c index e876d57..7171193 100644 --- a/kmer_frequency_per_sequence.c +++ b/kmer_frequency_per_sequence.c @@ -14,9 +14,10 @@ int main(int argc, char **argv) { long kmer = 6; size_t len = 0; ssize_t read; + unsigned long width = 0; 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); } @@ -26,8 +27,8 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + width = (int)pow(4, kmer); - int width = (int)pow(4, kmer); while ((read = getline(&line, &len, fh)) != -1) { if(line[0] != '>') { 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)]++; } |