Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CodeHippo
    Junior Member
    • Mar 2014
    • 4

    #1

    Counting Reads in BAM file by Region

    Greetings!

    I am a neophyte Bioinformaticist working with SAMtools for the very first time. To make matters worse, I have to work in Java, which is not a language I am particularly familiar with. To make matters even worse, it seems that most individuals run SAMtools functions through command line, while I am working towards compilable code in an IDE instead.

    My goal is to create java code that will count the number of reads in a region of a BAM file specified by the user. Could anyone start me off in the right direction by pointing out what specific SAMtools functions I should be looking at to accomplish this? I would be eternally grateful for any help.
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    Generally this is done using bedtools or featurecounts.

    http://bedtools.readthedocs.org/en/l.../coverage.html (https://github.com/arq5x/bedtools2)

    http://www.ncbi.nlm.nih.gov/pubmed/24227677 (http://subread.sourceforge.net)

    You will need samtools to generate the necessary BAM.
    Last edited by GenoMax; 03-24-2014, 10:54 AM.

    Comment

    • Brian Bushnell
      Super Moderator
      • Jan 2014
      • 2709

      #3
      Originally posted by CodeHippo View Post
      To make matters worse, I have to work in Java
      Nonono, Java makes things BETTER!

      But have you considered Picard? It has most or all of the functionality of samtools, and is written in Java, so you'll be able to access the bam-related functions directly.

      Comment

      • CodeHippo
        Junior Member
        • Mar 2014
        • 4

        #4
        Originally posted by Brian Bushnell View Post
        Nonono, Java makes things BETTER!

        But have you considered Picard? It has most or all of the functionality of samtools, and is written in Java, so you'll be able to access the bam-related functions directly.
        Picard is actually exactly what I'm using! I've found a very nice piece of Java code that uses Picard to count the total number of reads in a BAM file right here (courtesy of Andrew E. Bruno):



        My main issue now I suppose is figuring out how to take it a step further and use Picard to count only the number of reads within a specified region, and not the whole BAM file. I guess the real problem here isn't the Java, but the SAM/BAM terminology and interfaces that I'm not familiar with.

        I am searching through the javadoc for Picard and the BAMIndexMetaData Class looks like it has what I'm looking for, but I'm still not entirely sure how it works. Oh well, I guess it's back to flipping burgers for a living.

        Comment

        • mozack
          Junior Member
          • Jun 2013
          • 8

          #5
          The methods queryOverlapping() or queryContained() in SAMFileReader should give you want you want:

          http://picard.sourceforge.net/javado...ileReader.html

          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-15-2026, 10:52 AM
          0 responses
          13 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          20 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-13-2026, 09:56 AM
          0 responses
          19 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...