Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


  • Here's one of those cases where you have to be careful about separating standard output and standard error
    • cutadapt writes its FASTQ output to standard output by default, and writes summary information to standard error.
  • In this command we first redirect standard error to a log file named miRNA_test.cuta.log using the 2> syntax, in order to capture cutadapt diagnostics.
    • Then the remaining standard output is piped to gzip, whose output is the redirected to a new compressed FASTQ file.
    • (Read more about Standard streams and redirection)


titleInterpreting cutadapt I/O options

The cutadapt --help output describes its usage as follows:

    cutadapt -a ADAPTER [options] [-o output.fastq] input.fastq

From this we see that the input.fastq is a required argument. Clearly, it can be a FASTQ file, and it can be compressed based on this help:

                             Compressed input and output is supported and
auto-detected from the file name (.gz, .xz, .bz2).
Use the file name '-' for
standard input/output.

And this says that input reads can also be provided on standard input, if that argument is a hyphen ( - ). So input data can come:

  • from a file named as an argument:
    • cutadapt -a CGTAATTCGCG -o small.trim.fq  small.fq
    • and that input.fastq file can be provided in one of three compression formats
  • from standard input if the input.fastq argument is replaced with a dash ( - )
    • cat small.fq | cutadapt -a CGTAATTCGCG -o small.trim.fq  -

What about cutadapt output (the trimmed reads)? The brackets around the usage -o option indicate that the resulting trimmed FASTQ can be written to a file, but is not by default. This implies that cutadapt by default writes its results to standard output. So output can go

  • to a file, using the -o option
    • cutadapt -a CGTAATTCGCG -o small.trim.fq  small.fq
  • to standard output without the -o option
    • cutadapt -a CGTAATTCGCG small.fq 1> small.trim.fq

Finally, as we've seen, cutadapt also writes diagnostic output. Where does it go? The usage line doesn't say anything about diagnostics explicitly. But in the Output section of cutadapt --help:

   -o FILE, --output=FILE
        Write trimmed reads to FILE. FASTQ or FASTA format is
        chosen depending on input. The summary report is sent
        to standard output. Use '{name}' in FILE to
        demultiplex reads into multiple files. Default: write
to standard output

Careful reading of this suggests that:

  • When the trimmed output is sent to a file with the -o output.fastq option,
    • diagnostics are written to standard output
      • so can be redirected to a log file with 1> small.trim.log
    • cutadapt -a CGTAATTCGCG -o small.trim.fq  small.fq 1> small.trim.log
  • But when the -o option is omitted, and output goes to standard output,
    • diagnostics must be written to standard error
      • so can be redirected to a log file with 2> trim.log
    • cutadapt -a CGTAATTCGCG small.fq 1> small.trim.fq 2> small.trim.log