Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • genomeHunter
    Member
    • Apr 2013
    • 26

    #1

    Fast BAM sorting

    Hello,

    I have lots of unsorted BAM files and the sorting process is very slow. One solution I could think of was to run multiple instances of samtools:

    cat files.txt | xargs -n 1 -P $num_threads samtools sort

    The problem is that this method is I/O bound. Are there any (free) faster alternatives?

    Should I try novosort?

    Cheers
    GH
  • Heisman
    Senior Member
    • Dec 2010
    • 534

    #2
    Are you aware you can use samtools sort with multiple threads with the "-@" option?

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      If you are doing this on a cluster (with a storage subsystem that can support multiple I/O streams) Heisman's solution will work.

      If you are I/O bound on a single server then your only option is patience.
      Last edited by GenoMax; 07-19-2013, 11:58 AM.

      Comment

      • genomeHunter
        Member
        • Apr 2013
        • 26

        #4
        Originally posted by Heisman View Post
        Are you aware you can use samtools sort with multiple threads with the "-@" option?
        No, I was not. I saw the "-@" option in a fork of samtools, I guess it was called samtools-mt. I did not know it was added to samtools.

        Thanks,
        GH

        Comment

        • genomeHunter
          Member
          • Apr 2013
          • 26

          #5
          Originally posted by GenoMax View Post
          If you are doing this on a cluster (with a storage subsystem that can support multiple I/O streams) Heisman's solution will work.

          If you are I/O bound on a single server then your only option is patience.
          I tried it on a moderate-sized BAM file and it was not very fast on our mini-server (32 Cores and RAID-6 disk). I guess I will be using xargs :-)

          Cheers,
          GH

          Comment

          • Richard Finney
            Senior Member
            • Feb 2009
            • 701

            #6
            Please note the -m parameter for samtools sort , this is the amount of memory to use.
            Using available memory will speed up thing. This also works for novocraft's novosort. You may also wish to copy to a fast disk for any temp files that spill to disk.

            Comment

            • genomeHunter
              Member
              • Apr 2013
              • 26

              #7
              Originally posted by Richard Finney View Post
              Please note the -m parameter for samtools sort , this is the amount of memory to use.
              Using available memory will speed up thing. This also works for novocraft's novosort. You may also wish to copy to a fast disk for any temp files that spill to disk.
              Thanks. I am using 4GB/threads and 16 threads. Our main disk is a 12-disk RAID-6 arrays with enterprise-level HDDs.

              Do you know how does samtools sort compare to SortSam and NovoSort?

              Cheers,
              GH

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                Originally posted by genomeHunter View Post
                Our main disk is a 12-disk RAID-6 arrays with enterprise-level HDDs.

                Cheers,
                GH
                How is it connected to the server: 6 Gbps SAS/8 Gbps Fiber Channel HBA?

                Comment

                • genomeHunter
                  Member
                  • Apr 2013
                  • 26

                  #9
                  Originally posted by GenoMax View Post
                  How is it connected to the server: 6 Gbps SAS/8 Gbps Fiber Channel HBA?
                  I am not 100% sure but it must be 6 Gbps SAS.

                  GH

                  Comment

                  • lh3
                    Senior Member
                    • Feb 2008
                    • 686

                    #10
                    Multi-threading is available in the released package. Novosort is faster than samtools.

                    Comment

                    • genomeHunter
                      Member
                      • Apr 2013
                      • 26

                      #11
                      Originally posted by lh3 View Post
                      Multi-threading is available in the released package. Novosort is faster than samtools.
                      Do you have any rough speedup factors? I tried

                      samtools view -buS exp.sam | samtools sort -@ 16 -m 4G - sorted

                      And it takes 10 minutes for a moderate size SAM file.

                      Cheers,
                      GH

                      Comment

                      • GenoMax
                        Senior Member
                        • Feb 2008
                        • 7142

                        #12
                        GH: Here are some systems tools to check if any hardware bottlenecks exist on your system. Start with the "iostat": http://www.thegeekstuff.com/2011/07/...stat-examples/

                        Comment

                        Latest Articles

                        Collapse

                        • SEQadmin2
                          Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                          by SEQadmin2



                          CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                          Despite this, “CRISPR helped turn genome editing from a specialized technique into
                          ...
                          07-31-2026, 11:01 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
                          ...
                          07-20-2026, 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, 08-03-2026, 10:13 AM
                        0 responses
                        15 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-31-2026, 02:55 AM
                        0 responses
                        32 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-24-2026, 12:17 PM
                        0 responses
                        23 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-23-2026, 11:41 AM
                        0 responses
                        21 views
                        0 reactions
                        Last Post SEQadmin2  
                        Working...