marcelm / cutadapt

Cutadapt removes adapter sequences from sequencing reads
https://cutadapt.readthedocs.io
MIT License
502 stars 126 forks source link

Cutadapt writes some errors to STDOUT instead of STDERR #767

Closed johanneskoester closed 3 months ago

johanneskoester commented 3 months ago

Cutadapt writes its logging output and errors to STDOUT. According to the docs, I expected report information (qc stats) on STDOUT, but logging and errors on STDERR. Did I misunderstand that?

cutadapt 4.6 insallation via mamba env:

_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
bzip2                     1.0.8                hd590300_5    conda-forge
ca-certificates           2024.2.2             hbcca054_0    conda-forge
cffi                      1.16.0          py310h2fee648_0    conda-forge
cutadapt                  4.6             py310h4b81fae_1    bioconda
dnaio                     1.2.0           py310h4b81fae_0    bioconda
isa-l                     2.31.0               hd590300_1    conda-forge
ld_impl_linux-64          2.40                 h41732ed_0    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-ng                 13.2.0               h807b86a_5    conda-forge
libgomp                   13.2.0               h807b86a_5    conda-forge
libnsl                    2.0.1                hd590300_0    conda-forge
libsqlite                 3.45.1               h2797004_0    conda-forge
libstdcxx-ng              13.2.0               h7e041cc_5    conda-forge
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libxcrypt                 4.4.36               hd590300_1    conda-forge
libzlib                   1.2.13               hd590300_5    conda-forge
ncurses                   6.4                  h59595ed_2    conda-forge
openssl                   3.2.1                hd590300_0    conda-forge
pbzip2                    1.1.13               h1fcc475_2    conda-forge
pigz                      2.8                  h2797004_0    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
python                    3.10.13         hd12c33a_1_cpython    conda-forge
python-isal               1.6.0           py310h2372a71_0    conda-forge
python_abi                3.10                    4_cp310    conda-forge
readline                  8.2                  h8228510_1    conda-forge
setuptools                69.1.1             pyhd8ed1ab_0    conda-forge
tk                        8.6.13          noxft_h4845f30_101    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
wheel                     0.42.0             pyhd8ed1ab_0    conda-forge
xopen                     1.9.0           py310hff52083_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zstandard                 0.22.0          py310h1275a96_0    conda-forge
zstd                      1.5.5                hfc55251_0    conda-forge
marcelm commented 3 months ago

This has historic reasons, but I agree this needs some fixing.

When Cutadapt is used without an output file name (via -o), the only choice is to send all FASTA/FASTQ data to stdout and to send everything else (errors, report, other logging) to stderr. For consistency (well, and because it was easier to implement ...), when you provide -o, the only change is that all this is sent to stdout instead of stderr.

I cannot really make a distinction between logging and the QC report because the log is the report. For example, MultiQC parses the This is cutadapt ... line to recognize Cutadapt logs, so this needs to be part of the report.

Maybe what prompted you to file this issue is that a command like this (which fails) prints nothing on stderr:

cutadapt -o out.fastq nonexistentfile.fastq > report.log

I agree it makes more sense to always send errors to stderr. Would that resolve the issue for you?

johanneskoester commented 3 months ago

Yes, if errors are on stderr I would be happy :-)

johanneskoester commented 3 months ago

Since I will have to fix the snakemake wrapper for cutadapt: chances for a quick release with that change (then no wrapper change is needed)? Otherwise, I would for now change the wrapper.

marcelm commented 3 months ago

Sure, I can make a new release today.

marcelm commented 3 months ago

Version 4.7 is out, and the Bioconda recipe update should also get merged soon.

johanneskoester commented 3 months ago

Oh, seen it, thank you!