Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brofallon
    Member
    • May 2011
    • 26

    #1

    A faster read sorter

    Hello,
    I recently developed a fast stream-based .SAM sorter, streamsorter. It reads .SAM output from a stream (for instance, produced by bwa or another aligner), sorts the reads as they come in, and emits everything to standard out. Because this happens during alignment, and sorting is much faster than aligning, sorting takes essentially no extra time.

    Here's the basic usage for use with bwa:

    (long bwa command to create alignment) | sorter > sorted.sam

    Or if you prefer bam output:

    (long bwa command to create alignment) | sorter | samtools view -Sb - > sorted.bam

    For big alignments this can easily shave a substantial amount of time from the pipeline. Enjoy! Let me know if you find a bug or have other feedback.
    Last edited by brofallon; 04-25-2013, 02:02 PM.
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    How is this better than doing this via samtools? i.e. aligner -> {SAM} -> samtools view -> {uncompressed BAM} -> samtools sort -> {sorted BAM}

    Code:
    $ alignment arg1 arg2 ... | samtools -S -u - | samtools sort - prefix

    Comment

    • brofallon
      Member
      • May 2011
      • 26

      #3
      Huh... that -u option on samtools view does seem to speed things up a bit. Stream sorter is still a bit faster for two reasons. First, it doesn't depend on piping anything though samtools view to make an uncompressed bam that samtools sort can read. Second, samtools sort doesn't create bams very quickly. Streamsorter allows plugging in faster bamifier:

      Time to align, sort, and bamify ~500MB fastq;
      BWA mem + samtools : 643 seconds
      BWA mem + sorter : 594 seconds
      BWA mem + sorter + samtools-mt to create bam: 495 seconds

      Where samtools-mt is multithreaded samtools with 4 threads.
      OK, not a huge speedup. But we look for everything we can get around here....

      Comment

      • maubp
        Peter (Biopython etc)
        • Jul 2009
        • 1544

        #4
        Try some larger files - the speedup may be more visible then.

        I'd have to look at the code, but in principle 'samtools sort' could be extended to accept SAM as an input option.

        Comment

        • oiiio
          Senior Member
          • Jan 2011
          • 105

          #5
          just wanted to say that novosort (novocraft.com) is probably the fastest read sorting I have seen.

          In second place is the OpenGE's mergesort function which is open source (git://github.com/adaptivegenome/openge.git)

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
            by SEQadmin2



            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
            ...
            10-14-2026, 09:55 AM
          • SEQadmin2
            New Genomics Technologies Take Aim at Long-Standing Limits
            by SEQadmin2


            Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

            We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
            ...
            09-28-2026, 10:25 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Yesterday, 10:52 AM
          0 responses
          8 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          19 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-13-2026, 09:56 AM
          0 responses
          15 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-09-2026, 11:14 AM
          0 responses
          27 views
          0 reactions
          Last Post SEQadmin2  
          Working...