Errors, raised by samtools view ... | samtools sort ... aren't reported, due to the buffering of sys.stderr. In my case the error was:
[samopen] SAM header is present: 25 sequences.
Parse error at line 31: sequence and quality are inconsistent
Instead of outputting the error bwa-meth printed the following traceback:
Traceback (most recent call last):
File "/home/user/.virtualenvs/env/bin/bwameth.py", line 10, in <module>
execfile(__file__)
File "/home/user/.virtualenvs/env/src/bwameth-head/bwameth.py", line 596, in <module>
main(sys.argv[1:])
File "/home/user/.virtualenvs/env/src/bwameth-head/bwameth.py", line 581, in main
set_as_failed=args.set_as_failed)
File "/home/user/.virtualenvs/env/src/bwameth-head/bwameth.py", line 259, in bwa_mem
as_bam(cmd, fa, prefix, calmd, set_as_failed)
File "/home/user/.virtualenvs/env/src/bwameth-head/bwameth.py", line 296, in as_bam
out.write(str(aln) + '\n')
IOError: [Errno 32] Broken pipe
The traceback makes perfect sense, because after reporting the error samtools exited and the file descriptor behind out became stale. However, the original error is much more helpful.
Errors, raised by
samtools view ... | samtools sort ...
aren't reported, due to the buffering ofsys.stderr
. In my case the error was:Instead of outputting the error
bwa-meth
printed the following traceback:The traceback makes perfect sense, because after reporting the error
samtools
exited and the file descriptor behindout
became stale. However, the original error is much more helpful.I'm ready to submit a patch for this.