Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • kmpf
    Junior Member
    • Apr 2013
    • 2

    Can Picards AddOrReplaceReadGroups output SAM format to Pipe?

    Hello,

    I'm using Picard tools, for instance AddOrReplaceReadGroups, within a unix pipe like this one:

    Code:
    unpigz --stdout -p 1 mapped_reads.sam.gz | \
    java -Xmx2g -jar AddOrReplaceReadGroups.jar INPUT=/dev/stdin OUTPUT=/dev/stdout \
    RGLB=some RGPL=illumina RGPU=adapter RGSM=name > mapped_reads.bam
    The output of the program is always in BAM format, if I use:
    Code:
    OUTPUT=/dev/stdout
    Is there a way to tell the program to write SAM format to STDOUT? This would be nice so I could further extend my pipeline.
  • aggp11
    Member
    • Jun 2011
    • 87

    #2
    I don't know if this will work, but you could try to pipe the output to samtools view to try to get the SAM output. e.g.

    unpigz --stdout -p 1 mapped_reads.sam.gz | \
    java -Xmx2g -jar AddOrReplaceReadGroups.jar INPUT=/dev/stdin OUTPUT=/dev/stdout \
    RGLB=some RGPL=illumina RGPU=adapter RGSM=name | samtools view -h - > mapped.sam

    The "-h" option would include the header in the output. I haven't tried this but I think this should work and this should be quick check.

    Hope this helps!
    Praful

    Comment

    • kmpf
      Junior Member
      • Apr 2013
      • 2

      #3
      Thanks for your quick answer. I tried it the way you described it. It seems to work fine.

      Eventhough this workaround works, it would have been nice of Picard to provide a defined switch to choose the output format.

      Many thanks,
      Christoph

      Comment

      • Timothy Amos
        Junior Member
        • Aug 2014
        • 4

        #4
        Named pipe

        Another solution is to make a named pipe i.e.:

        Code:
        mkfifo foo.sam
        you should be able to set foo.sam as your output file, run that part of your pipeline in the background and use foo.sam as an input file in another command running at the same time. e.g.:

        Code:
        unpigz --stdout -p 1 mapped_reads.sam.gz | \
        java -Xmx2g -jar AddOrReplaceReadGroups.jar INPUT=/dev/stdin OUTPUT=foo.sam \
        RGLB=some RGPL=illumina RGPU=adapter RGSM=name &
        Code:
        java -Xmx1g program1.jar I=foo.sam O=/dev/stdout | java -Xmx1g program2.jar I=/dev/stdin O=/dev/stdout
        See http://sourceforge.net/p/samtools/ma...sage/25870969/ for a discussion on piping and picard tools and the speed benefits of using uncompressed bam files over uncompressed sam files.

        hth,

        Tim

        Comment

        Latest Articles

        Collapse

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 06-09-2026, 11:58 AM
        0 responses
        30 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-05-2026, 10:09 AM
        0 responses
        38 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-04-2026, 08:59 AM
        0 responses
        43 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 06-02-2026, 12:03 PM
        0 responses
        64 views
        0 reactions
        Last Post SEQadmin2  
        Working...