statgen / bamUtil

http://genome.sph.umich.edu/wiki/BamUtil
87 stars 29 forks source link

Option to output bamUtil stats to STDOUT rather than to a file #44

Closed dylkot closed 7 years ago

dylkot commented 7 years ago

Hi There,

I am using bamUtil stats to analyze some whole-genome sequencing data like so

curl url_for_my_large_bam.bam | ./bam stats --in -.ubam --cBaseQC results.txt

and results.txt is really large. I would love to be able to pipe it to awk to do some filtering. It seems like it would be pretty easy to add an option to write to STDOUT. Is this an option I am missing or would it be possible to add?

Thanks, Dylan

pjvandehaar commented 7 years ago
curl url_for_my_large_bam.bam | ./bam stats --in -.ubam --cBaseQC -

works for me. I just added - to bam stats --help in the commit https://github.com/statgen/bamUtil/commit/eb542172119d0f2b43ede03f24163f88e3478340 .

In general, any time that you want to pipe something to stdout using a filename, you can use /dev/fd/1. Example:

curl url_for_my_large_bam.bam | ./bam stats --in -.ubam --cBaseQC /dev/fd/1 2>/dev/null | cut -f1 | uniq -c

(The 2>/dev/null discards the line Number of records read = 10000.)

dylkot commented 7 years ago

HI pjvandehaar, thank you for the tip! I will use that.