Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #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


    • #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


      • #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


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

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Advancing Precision Medicine for Rare Diseases in Children
            by seqadmin




            Many organizations study rare diseases, but few have a mission as impactful as Rady Children’s Institute for Genomic Medicine (RCIGM). “We are all about changing outcomes for children,” explained Dr. Stephen Kingsmore, President and CEO of the group. The institute’s initial goal was to provide rapid diagnoses for critically ill children and shorten their diagnostic odyssey, a term used to describe the long and arduous process it takes patients to obtain an accurate...
            12-16-2024, 07:57 AM
          • seqadmin
            Recent Advances in Sequencing Technologies
            by seqadmin



            Innovations in next-generation sequencing technologies and techniques are driving more precise and comprehensive exploration of complex biological systems. Current advancements include improved accessibility for long-read sequencing and significant progress in single-cell and 3D genomics. This article explores some of the most impactful developments in the field over the past year.

            Long-Read Sequencing
            Long-read sequencing has seen remarkable advancements,...
            12-02-2024, 01:49 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 12-17-2024, 10:28 AM
          0 responses
          26 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-13-2024, 08:24 AM
          0 responses
          42 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-12-2024, 07:41 AM
          0 responses
          28 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-11-2024, 07:45 AM
          0 responses
          42 views
          0 likes
          Last Post seqadmin  
          Working...
          X