From c85897eed647dc993bf832c9e17bf77cf31f5f2d Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Thu, 7 Nov 2013 17:25:33 -0500 Subject: rename to counts per sequence, don't provide frequencies only counts --- kmer_counts_per_sequence.c | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'kmer_counts_per_sequence.c') diff --git a/kmer_counts_per_sequence.c b/kmer_counts_per_sequence.c index d518efc..66accc8 100644 --- a/kmer_counts_per_sequence.c +++ b/kmer_counts_per_sequence.c @@ -9,20 +9,20 @@ unsigned long position = 0; int main(int argc, char **argv) { - char *line = NULL; - size_t len = 0; - ssize_t read; + char *line = NULL; + size_t len = 0; + ssize_t read; - if(argc != 3) { - printf("Please supply a filename and a kmer\n"); - exit(EXIT_FAILURE); - } + if(argc != 3) { + printf("Please supply a filename and a kmer\n"); + exit(EXIT_FAILURE); + } - FILE *fh = fopen(argv[1], "r" ); - if(fh == NULL) { - fprintf(stderr, "Error opening %s - %s\n", argv[1], strerror(errno)); - exit(EXIT_FAILURE); - } + FILE *fh = fopen(argv[1], "r" ); + if(fh == NULL) { + fprintf(stderr, "Error opening %s - %s\n", argv[1], strerror(errno)); + exit(EXIT_FAILURE); + } unsigned long kmer = atoi(argv[2]); if(kmer == 0) { @@ -36,36 +36,36 @@ int main(int argc, char **argv) { if(counts == NULL) exit(EXIT_FAILURE); - while ((read = getline(&line, &len, fh)) != -1) { - if(line[0] != '>' && (read > kmer)) { + while ((read = getline(&line, &len, fh)) != -1) { + if(line[0] != '>' && (read > kmer)) { - unsigned int i = 0; - unsigned long total = 0; + unsigned int i = 0; + unsigned long total = 0; // reset our count matrix to zero memset(counts, 0, width * sizeof(unsigned long long)); - for(i = 0; i < read - kmer; i++) { + for(i = 0; i < read - kmer; i++) { line[i] = alpha[(int)line[i]]; } - for(i = 0; i < read - kmer; i++) { - counts[num_to_index(&line[i],kmer, width)]++; - } + for(i = 0; i < read - kmer; i++) { + counts[num_to_index(&line[i],kmer, width)]++; + } - for(i = 0; i < width; i++) - total += counts[i]; + for(i = 0; i < width; i++) + total += counts[i]; - for(i = 0; i < width - 1; i++) - printf("%llu\t", counts[i]); - printf("%llu\n", counts[width - 1]); + for(i = 0; i < width - 1; i++) + printf("%llu\t", counts[i]); + printf("%llu\n", counts[width - 1]); - } - } + } + } free(counts); - free(line); + free(line); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } -- cgit v1.2.3