Unconfigured Ad

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

    #1

    Getting Reference Name with Samtools/Picard

    Greetings,

    I am currently working in Picard, the java version of SAMtools. I am using the queryContained() method to count the number of reads in a BAM file by specified regions. This method requires an int start, int end, and String Name. I assume that the String Name value is the name of the reference sequence(s) in the BAM file. I tested this on a Human Chr20 BAM file from NCBI and found that I only got an output if I used "20" as my string name.

    Now here's my question: How can I make Picard check the BAM file for me and print out what the name of the reference sequence(s) is? I've tried incorporating the getReferenceName() method, but when I use it on the Chr20 BAM file, I always get "*" as an output. Here is a rough example of the logic I've tried so far:

    SAMFileReader reader = new SAMFileReader(bamFile, index);
    SAMFileHeader Bob = reader.getFileHeader();
    SAMRecord Jimmy = new SAMRecord(Bob);
    String Earl = Jimmy.getReferenceName();
    System.out.println(Earl);


    Any help will be greatly appreciated
  • lindenb
    Senior Member
    • Apr 2010
    • 143

    #2
    use sequence dictionary to get the list of reference sequences:
    http://picard.sourceforge.net/javado...ctionary%28%29

    Code:
    for(SAMSequenceRecord ssr:Bob.getSequenceDictionary().getSequences())
    {
    System.out.println(ssr.getSequenceName() );
    }

    Comment

    • CodeHippo
      Junior Member
      • Mar 2014
      • 4

      #3
      Thank you! That was exactly what I was looking for!

      Comment

      Latest Articles

      Collapse

      • kinpict.com
        Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
        by kinpict.com
        The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
        Today, 06:37 PM
      • SEQadmin2
        16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
        by SEQadmin2





        NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
        10-30-2026, 06:46 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 11-12-2026, 07:59 AM
      0 responses
      27 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 11-05-2026, 09:25 AM
      0 responses
      35 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 11-03-2026, 11:54 AM
      2 responses
      56 views
      0 reactions
      Last Post kinpict.com  
      Started by SEQadmin2, 10-28-2026, 09:57 AM
      0 responses
      175 views
      0 reactions
      Last Post SEQadmin2  
      Working...