Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cycomatto
    Junior Member
    • Dec 2011
    • 7

    #1

    BAM speed: i/o, uncompress, etc.

    Is anybody familiar with the relative speeds of .bam file i/o and decompression? My algorithm is bottlenecking when I try to load reads from a .bam file.

    Using BAMTools, I jump to certain, specific locations in the genome, and load the reads in a small region there (this involves decompression). I do this many, many times, loading many reads.

    I am thinking it may be more efficient to create a mini-BAM file (only the regions of concern), then load this into memory (cache it), and then search and load the reads. But will the required decompressing from the compressed .bam format still make things too slow?
  • Richard Finney
    Senior Member
    • Feb 2009
    • 701

    #2
    What data structure are you using to store the "loaded reads"?
    Seeking to an indexed bam file, reading in and uncompromising the data should not be a big problem.

    Comment

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

      #3
      You could try using an uncompressed BAM file (use the samtools view -u option), and see if that helps.

      Also does BAMtools attempt to cache any of the data to avoid repeated reading and decompressing the same BGZF blocks?

      Comment

      • cycomatto
        Junior Member
        • Dec 2011
        • 7

        #4
        Originally posted by Richard Finney View Post
        What data structure are you using to store the "loaded reads"?
        Seeking to an indexed bam file, reading in and uncompromising the data should not be a big problem.
        I am using the BamTools::BamAlignment data structure (std::string for qualities, read name, sequence, etc. bunch of ints and some bools)

        Comment

        • jkbonfield
          Senior Member
          • Jul 2008
          • 146

          #5
          If you're on a linux box I'd advise "strace -o trace.out -T program args" to list the system calls and times taken. This can help a lot in seeing what takes up the time.

          Generally random access is always going to be slow as disk seeks are typically slow. Some filesystems are better than others here too. Ultimately if you're doing a LOT of random access it may prove faster to copy it off a slow storage and onto something quick before doing the random I/O, eg a solid-state drive, or at the very least /tmp so the OS can do a better job of caching local data without making assumptions on networked I/O.

          A quick test: is it faster to do a full "samtools view filename.bam > /dev/null" than to do your random I/O? If so then seeking is probably your bottleneck.

          Do you have the option to sort the random access prior to running the algorithm? I.e. to ensure the small portions you're reading are always sequential.

          Comment

          • adaptivegenome
            Super Moderator
            • Nov 2009
            • 436

            #6
            I/O is a big bottleneck. I would not recommend using uncompressed SAMs because then you have even more data to move around. Is your tool parallelized? If so BAM reading could be a bottleneck because bamtools implements its IO serially.

            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, 10-22-2026, 11:13 AM
            0 responses
            33 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 10-22-2026, 10:48 AM
            0 responses
            23 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 10-15-2026, 10:52 AM
            0 responses
            41 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 10-14-2026, 05:39 AM
            0 responses
            45 views
            0 reactions
            Last Post SEQadmin2  
            Working...