This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Samtools Depth Can Only Have Stdout?

Hi, everyone! I want to have a look at the depth of each position in my .bam file, so, the samtools used,samtools depth my.bam, but I find I can't get the output parameter, it only output in my Terminal screen. I want a file with whole positions' depth. How can I do it? Thx!

samtools depth-of-coverage output

3 answers

In unix you can redirect stdout to file:

samtools mpileup bam > out.txt

Thx a lot. So simple, I am really a Novice!!

if you like the answer, accept it with a tick.

Does mpileup and depth have any difference?

I suppose you just want to redirect the output of your command into a file. This is not a bioinformatics question, but a UNIX question.

Anyway, you should use the redirection character (>) and your syntax should look like:

samtools_command -andoptions inputfile > outputfile

Thanks a lot!!!!

try to use the pipeline redirection: http://www.codecoffee.com/tipsforlinux/articles2/042.html

samtools depth file.bam > result.txt

Warm-hearted person!

Log in to answer this question.