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
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
Comment