aboutsummaryrefslogtreecommitdiff
path: root/kmer_total_count.c
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2013-09-11 09:43:33 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2013-09-11 09:43:33 -0400
commit12fd24e056d18e9f7ee8e1e47a42e47c843c98ff (patch)
treea359b48441b1f3cbe9561a26a9a273fd9d5c6fa4 /kmer_total_count.c
parentf52d24cd7099fc930fca785ec65401de50cd931d (diff)
move declarations to top, make sure to use the appropriate type
Diffstat (limited to 'kmer_total_count.c')
-rw-r--r--kmer_total_count.c18
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)]++;
}