Unconfigured Ad

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

    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

                        • GATTACAT
                          Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                          by GATTACAT
                          Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                          07-01-2026, 11:43 AM
                        • SEQadmin2
                          Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                          by SEQadmin2


                          I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

                          Here are nine questions we think about, in roughly the order they matter, before...
                          06-18-2026, 07:11 AM

                        ad_right_rmr

                        Collapse

                        News

                        Collapse

                        Topics Statistics Last Post
                        Started by SEQadmin2, 07-02-2026, 11:08 AM
                        0 responses
                        25 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 06-30-2026, 05:37 AM
                        0 responses
                        23 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 06-26-2026, 11:10 AM
                        0 responses
                        23 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 06-17-2026, 06:09 AM
                        0 responses
                        55 views
                        0 reactions
                        Last Post SEQadmin2  
                        Working...