Entering edit mode
10.6 years ago
dariober
15k
Hello,
I'm trying to use the Java API for picard/samtools to write a BAM file to standard output.
With the code below I can write SAM to stdout. However, I would like to write directly as BAM to stdout. Is it possible?
SAMFileWriterFactory sf= new SAMFileWriterFactory();
SAMFileWriter sw= sf.makeSAMWriter(mySamFileHeader, false, System.out);
sw.addAlignment(mySamRecord);
Many thanks
Dario
Thanks Pierre! Your first option would work but I'm a bit reluctant to hard-coding "/dev/stdout". Your second option however put me in the right direction. This seems to work: