diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2014-01-31 10:45:38 -0500 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2014-01-31 10:45:38 -0500 |
commit | 1a1392cfed14578eaae020cdcf968d66e82d8e64 (patch) | |
tree | 425cf738c898249e0c6a47ebf63baf6ab36b8c1d /kmer_total_count.c | |
parent | 811ea4d31d1d823d8ef2e0656e183aaf671d4502 (diff) |
read from stdin if -i not supplied, also add strerror for information if opening file doesn't work:fgmutant-refactor-total-count
Diffstat (limited to 'kmer_total_count.c')
-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); |