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
          Essential Discoveries and Tools in Epitranscriptomics
          by seqadmin




          The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
          04-22-2024, 07:01 AM
        • seqadmin
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        59 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        57 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        53 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        56 views
        0 likes
        Last Post seqadmin  
        Working...
        X