biod / sambamba

Tools for working with SAM/BAM data
http://thebird.nl/blog/D_Dragon.html
GNU General Public License v2.0
558 stars 104 forks source link

Debug version: SAM output of CRAM file is populated with debug on pipe #328

Closed hzpc-joostk closed 6 years ago

hzpc-joostk commented 6 years ago

The SAM output of a CRAM file is unintentionally populated with debug lines.

sambamba 0.6.7

This version was built with:
    LDC 1.1.1
    using DMD v2.071.2
    using LLVM 3.8.1
    bootstrapped with LDC - the LLVM D compiler (0.17.4)
samtools 1.6
Using htslib 1.6
Copyright (C) 2017 Genome Research Ltd.

System version:

uname --kernel-release && cat /etc/system-release
2.6.32-696.3.1.el6.x86_64
CentOS release 6.9 (Final)
htsfile sampleX.aln.cram
sampleX.aln.cram:   CRAM version 3.0 compressed sequence data
sambamba view -C -h sampleX.aln.cram 2>/dev/null | less -S

Would return SAM format on stdout:

  1. the header
  2. debug lines
cram_read_container
COPIED #2
COPIED #2
COPIED #2
cram_read_container
COPIED #3
COPIED #3
COPIED #3
...
cram_read_container
COPIED #4
COPIED #4
COPIED #4
COPIED #4
COPIED #4
COPIED #5
COPIED #69
COPIED #69
COPIED #69
cram_read_container
COPIED #5
COPIED #5
COPIED #5
COPIED #5
COPIED #5
  1. alignments

Looking at stderr:

sambamba view -C -h sampleX.aln.cram 2>&1 1>/dev/null | less

The output is:

Init cram_fd* #1
Init cram_fd* #2
Init _Anonymous_25* #1
cram_read_slice (1/1)
Init cram_slice* #1
Init _Anonymous_25* #2
cram_read_slice (1/1)
Init cram_slice* #2
Init _Anonymous_25* #3
cram_read_slice (1/1)
...
Init cram_slice* #69
Init _Anonymous_5* #4
Free _Anonymous_5* #3
Free cram_slice* #3
Free _Anonymous_25* #3

The debug line on stdout is written on this line: cram/wrappers.d#L162

Problem occurs in both Zsh and Bash.

pjotrp commented 6 years ago

I suppose debug output should be on stderr

hzpc-joostk commented 6 years ago

That is what I would expect. These debug lines are output on stdout:

cram_read_container
COPIED #2

For me, it would be nicer to silence all debug messages, even on stderr, by default.

pjotrp commented 6 years ago

Oh, I see. If you use the real release of sambamba debug info should be off. I'll fix this at some point. If you want to use the debug version (nevertheless) don't pipe the output. Write it to a file.