I'm new to htsjdk and bam file so I would really appreciate your help to get started on this.
My first goal is simple. I want to use a .bai to random access a position in .bam given chromosome and position. Then I want to count the number of reads for ref allele, and the number of reads for alt allele that have MapQuality above certain value at that position.
I am using HTSJDK, but I found it difficult to find exactly what I need from its long documentation.
So far I've only been able to open the file, thanks to Pierre Lindenbaum's previous post:
SamReaderFactory srf=SamReaderFactory.make();
srf.validationStringency(ValidationStringency.LENIENT);
SAMFileReader samReader=new SAMFileReader(vsFile, new File(bai));
//I know SAMFileReader is deprecated, but I dont know what's the new equivalent
AbstractBAMFileIndex index=(AbstractBAMFileIndex) samReader.getIndex();
SAMRecordIterator iter=samReader.iterator();
Even that's not really what I want, since I need to be able to random access it.
So yea, didn't go very far, any help is much appreciated!!!
htsjdk
java
next-gen
genome
alignment