This is a test version of Biostars. For the public version, visit https://www.biostars.org.
prevent [samopen] from being printed by samtools

I am calling samtools as a subprocess from a script, many times. Each time it runs I get a message to the screen that says [samopen] SAM header is present: X sequences. I have tried to redirect it, but have not been successful. I don't see any kind of "quiet" mode option in samtools. Is there a way to make this not print every time I call samtools?

alignment subprocess samtools

2 answers

Redirect stderr to /dev/null http://askubuntu.com/questions/350208/what-does-2-dev-null-mean

cmd 2> /dev/null

Thanks for a quick response. I tried that and it didn't seem to work, although my call piped output to another call, so I just had to relocate the stderr redirect to the first call and now it works (duh). Thank you!

Aside from redirecting stderr to /dev/null, as Pierre mentioned, you could also just using a more recent version of samtools. I think version 0.1.19 was the last one to do this (github seems to confirm this).

Oh! thanks for the tip. I will also update.

Log in to answer this question.