aboutsummaryrefslogtreecommitdiff
path: root/kmer_total_count.c
diff options
context:
space:
mode:
authororbitz <orbitz@gmail.com>2013-12-29 12:36:37 +0100
committerorbitz <orbitz@gmail.com>2013-12-29 12:36:37 +0100
commitc2dfccab8aa22f308dc572b18658036e9db01107 (patch)
tree9f9a89cbfe2f526d461dad629da5fe76aea10361 /kmer_total_count.c
parentda0825a749c0879a6aff8731a7d6c716e68d89e8 (diff)
Refactor to pull opening the file out of the count function
Diffstat (limited to 'kmer_total_count.c')
-rw-r--r--kmer_total_count.c9
1 files changed, 8 insertions, 1 deletions
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) {