           (if min-sequence-length (str min-sequence-length) "-")
         max-sequence-length-str
           (if max-sequence-length (str max-sequence-length) "-")
+        ;; Output fields are tab separated.
         output-str (str filename "\t"
                         num-sequences-str "\t"
                         num-bases-str "\t"

        options-summary]
       (string/join \newline)))

(defn error-msg [errors]
  (str "The following errors occurred while parsing your command:\n\n"
       (string/join \newline errors)))

(defn exit [status msg]
  (println msg)
  (System/exit status))

(def default-minlen 0)

(def cli-options
  [[nil "--minlen N" "Minimum length sequence to include in stats"

                        max-sequence-length-str)]
  (println output-str)))


(defn seq-length-gte-minlen?
  "Test if the length of a sequence is >= to a minimum value.

  Arguments:
    minlen: The minimum length sequence allowed (non-negative int).
    record: A FASTA record.

  Result:
    true if the sequence length is >= minlen, false otherwise."

  [minlen record]
  (let [sequence (:sequence record)
        num-bases (count sequence)]
    (>= num-bases minlen)))


(defn process-fasta-reader
  "Compute the statistics for a single input FASTA file from a reader object,
  and pretty print the result to the standard output.

  Arguments:
    minlen: The minimum length sequence allowed (non-negative int). Sequences shorter than
      this will be skipped by the program.
    filename: The name of the file being processed, printed in the output.
    reader: The reader object representing the input FASTA file contents.

  Result:
    nil"
    
  [minlen filename reader]
    (print-results filename
      (reduce
        update-stats
        initial-stats 
        (filter
          (fn [record] (seq-length-gte-minlen? minlen record))
          (bs/biosequence-seq reader)))))


(defn process-fasta-file 
  [minlen filename]
  (timbre/info "Processing FASTA file from" filename)
  (with-open [reader (bs/bs-reader (bs/init-fasta-file filename :iupacAminoAcids))]
    (process-fasta-reader minlen filename reader)))


(defn process-stdin
  [minlen]
  (timbre/info "Processing FASTA file from stdin")
  (with-open [reader (bs/init-fasta-reader (java.io.BufferedReader. *in*) :iupacAminoAcids)]
    (process-fasta-reader minlen "stdin" reader)))


(def header "FILENAME\tTOTAL\tNUMSEQ\tMIN\tAVG\tMAX")


(defn process-fasta-files
  [minlen files]
