SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
PICARD/ReorderSam reference problem twotwo Bioinformatics 2 04-13-2018 11:12 PM
samtools picard SamFormatConverter Bio.X2Y Bioinformatics 3 07-08-2013 07:46 AM
Picard versus SAMtools ? Which one is better? prs321 Bioinformatics 9 06-25-2013 05:41 AM
Who is the culprit? Picard, Samtools or GATK? newbietonextgen Bioinformatics 2 07-16-2012 05:47 PM
samtools vs picard index pallo Bioinformatics 1 04-11-2011 03:59 PM

Reply
 
Thread Tools
Old 04-14-2014, 05:53 PM   #1
CodeHippo
Junior Member
 
Location: Illinois

Join Date: Mar 2014
Posts: 4
Default 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
CodeHippo is offline   Reply With Quote
Old 04-14-2014, 10:24 PM   #2
lindenb
Senior Member
 
Location: France

Join Date: Apr 2010
Posts: 143
Default

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() );
}
lindenb is offline   Reply With Quote
Old 04-15-2014, 12:45 PM   #3
CodeHippo
Junior Member
 
Location: Illinois

Join Date: Mar 2014
Posts: 4
Default

Thank you! That was exactly what I was looking for!
CodeHippo is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 03:30 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO