Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • malbuquerque
    Junior Member
    • Oct 2013
    • 4

    samtools piping problem

    Hello SEQanswers,

    My ultimate goal is to pipe multiple different regions of a bam file to different commands in a single command line argument.

    Basically, I am trying to generate some metrics from a BAM file that will be flagged for optical duplicates and then (without storing to disc) I want to pipe each chromosome to a program.

    ex.

    java -jar picard/MarkDuplicates.jar I=test.bam O=/dev/stdout | tee >(samtools view 'chr1' -| ./generate_metrics) >(samtools view 'chr2' -| ./generate_metrics) ...

    any advice if my current implementation isn't the best?
    The issue right now is attempting to pull a segment from the bamfile after an initial pipe.

    Thanks,

    Marco
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Well, that works, put the command is going to get really unwieldy. Why don't you either pipe to a perl/python/whatever script and have it pipe accordingly (the input to MarkDuplicates is already sorted, so your script would just need to pipe to one instance of ./generate_metrics at a time) or just rewrite ./generate_metrics to handle multiple chromosomes (assuming you have the source code).

    Comment

    • malbuquerque
      Junior Member
      • Oct 2013
      • 4

      #3
      The idea is to parrallel these operations. So I will ultimately be submitting qsubs for each chromosomes operations, Its just a matter of segmenting the BAM file into its appropriate segments.

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        I'd be a little surprised if piping like that into qsub would actually work. If you want to parcel this out to multiple nodes, why don't you just markDuplicates on a chromosome per node and generate_metrics on that?

        Comment

        • malbuquerque
          Junior Member
          • Oct 2013
          • 4

          #5
          That sound like a great idea

          Thanks! The duplicate algorithm (im assuming) is only looking for reads of the same length and position correct (i.e. there wont be duplicates accross different chromosomes).

          Comment

          • dpryan
            Devon Ryan
            • Jul 2011
            • 3478

            #6
            I think it just looks at the 5' position of both mates in a pair and marks duplicates if there are multiple pairs with the same 5' position(s). I could be misremembering that, though.

            Comment

            • malbuquerque
              Junior Member
              • Oct 2013
              • 4

              #7
              So this is what I'm thinking from what you have told me

              samtools view sample.bam 'chr1' | java -jar $PICARDROOT/MarkDuplicates.jar I= - O=sample_chr1.bam M=metrics_chr1.txt

              Or is there something else I need to pass to I...

              Comment

              • dpryan
                Devon Ryan
                • Jul 2011
                • 3478

                #8
                Yeah, but I'd forgotten that MarkDuplicates can't take input via a pipe, so that won't work. I'm not coming up with a way to do that that doesn't end up involving considerable programming with MPI. Do you have the code for generate_metrics? It would seem easier to just write it to handle multiple contigs. Alternatively, presuming that actually marking the duplicates is the rate limiting step, then just run it on a single node.

                Comment

                • dpryan
                  Devon Ryan
                  • Jul 2011
                  • 3478

                  #9
                  Oh, have a look at Biobambam, which can MarkDuplicates but writes its temp files to a local disk (it's geared more toward clusters). BTW, see also this thread on Biostars.

                  Comment

                  • rhinoceros
                    Senior Member
                    • Apr 2013
                    • 372

                    #10
                    Maybe gnuparallel could solve your parallelization? This thread explains it comprehensively..
                    savetherhino.org

                    Comment

                    Latest Articles

                    Collapse

                    • mylaser
                      Reply to Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                      by mylaser
                      The world of online gaming has grown tremendously over the past few years, giving players access to exciting sports, casino games, and interactive entertainment from the comfort of their homes. Among the platforms gaining attention, Kheloyaar has become a trusted destination for users seeking a fast, secure, and engaging gaming experience.
                      Whether you're a first-time visitor or an existing user, understanding the features of Kheloyar and the Kheloyaar login process can help you enjoy everything...
                      Today, 12:33 AM
                    • SEQadmin2
                      Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                      by SEQadmin2


                      Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                      The systematic characterization of the human proteome has
                      ...
                      Yesterday, 11:48 AM
                    • SEQadmin2
                      Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                      by SEQadmin2



                      Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                      ...
                      07-09-2026, 11:10 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by SEQadmin2, Yesterday, 11:10 AM
                    0 responses
                    8 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-13-2026, 10:26 AM
                    0 responses
                    30 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-09-2026, 10:04 AM
                    0 responses
                    39 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-08-2026, 10:08 AM
                    0 responses
                    25 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...