diff options
-rw-r--r-- | kmer_total_count.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/kmer_total_count.c b/kmer_total_count.c index 2f944d8..2b4f548 100644 --- a/kmer_total_count.c +++ b/kmer_total_count.c @@ -62,9 +62,16 @@ int main(int argc, char **argv) { } } if(filename == NULL) { - fprintf(stderr, "Error: filename (-i) must be supplied\n"); - exit(EXIT_FAILURE); + fprintf(stderr, "not input file specified with -i, reading from stdin\n"); + fh = stdin; } + else { + fh = fopen(filename, "r"); + if(fh == NULL) { + fprintf(stderr, "Could not open %s - %s\n", filename, strerror(errno)); + exit(EXIT_FAILURE); + } + } if(kmer == 0 && !kmer_set) { fprintf(stderr, "Error: kmer (-k) must be supplied\n"); exit(EXIT_FAILURE); @@ -74,12 +81,6 @@ 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 = kmer_pow_four(kmer); unsigned long long *counts = kmer_counts_from_file(fh, kmer); |