From c2dfccab8aa22f308dc572b18658036e9db01107 Mon Sep 17 00:00:00 2001 From: orbitz Date: Sun, 29 Dec 2013 12:36:37 +0100 Subject: Refactor to pull opening the file out of the count function --- kmer_total_count.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'kmer_total_count.c') diff --git a/kmer_total_count.c b/kmer_total_count.c index f15b69c..5ce7ee1 100644 --- a/kmer_total_count.c +++ b/kmer_total_count.c @@ -12,6 +12,7 @@ int main(int argc, char **argv) { char *filename = NULL; + FILE *fh; unsigned int kmer = 0; @@ -76,9 +77,15 @@ int main(int argc, char **argv) { exit(EXIT_FAILURE); } + fh = fopen(filename, "r"); + if(fh == NULL) { + fprintf(stderr, "Could not open %s\n", filename); + exit(EXIT_FAILURE); + } + width = pow_four(kmer); - unsigned long long *counts = get_kmer_counts_from_file(filename, kmer); + unsigned long long *counts = get_kmer_counts_from_file(fh, kmer); // If nonzero is set, only print non zeros if(nonzero) { -- cgit v1.2.1