Header Leaderboard Ad

Collapse

Can Picards AddOrReplaceReadGroups output SAM format to Pipe?

Collapse

Announcement

Collapse

SEQanswers June Challenge Has Begun!

The competition has begun! We're giving away a $50 Amazon gift card to the member who answers the most questions on our site during the month. We want to encourage our community members to share their knowledge and help each other out by answering questions related to sequencing technologies, genomics, and bioinformatics. The competition is open to all members of the site, and the winner will be announced at the beginning of July. Best of luck!

For a list of the official rules, visit (https://www.seqanswers.com/forum/sit...wledge-and-win)
See more
See less
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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Yesterday, 10:20 AM
        0 responses
        9 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-07-2023, 07:14 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-06-2023, 01:08 PM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 06-01-2023, 08:56 PM
        0 responses
        166 views
        0 likes
        Last Post seqadmin  
        Working...
        X