Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #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


    • #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


      • #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

        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM
        • seqadmin
          Techniques and Challenges in Conservation Genomics
          by seqadmin



          The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

          Avian Conservation
          Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
          03-08-2024, 10:41 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Yesterday, 06:37 PM
        0 responses
        8 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, Yesterday, 06:07 PM
        0 responses
        8 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-22-2024, 10:03 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 03-21-2024, 07:32 AM
        0 responses
        66 views
        0 likes
        Last Post seqadmin  
        Working...
        X