> As such is there a specific function in the htsjdk to retrieve the number
> of reads/alignments that cover a specific position i.e. chr2:10,000?
> Or is this something that requires some coding, say iterating through a
> query from a SamReader? If so does any one have any recommendations/code
> snippets for the most efficient way to do this?
>

Hi,
That's a synopsis of how I would do it. If there are better ways I'd like
to know myself!
Dario

public void getDepthAtInterval(){

String chrom= "chr1";

int from= 1000;

int to= 2000;

SamReader samReader = ...// Get a SamRaader obj;

// Loci to sample (could be a single position):

IntervalList il= new IntervalList(samReader.getFileHeader());

il.add(new Interval(chrom, from, to));

// Start iterating through loci:

SamLocusIterator samLocIter= new SamLocusIterator(samReader, il, true);

samLocIter.setSamFilters(filters); // Optional list of List<SamRecordFilter>

Iterator<SamLocusIterator.LocusInfo> iter= samLocIter.iterator();

while(iter.hasNext()){

LocusInfo locusInfo= iter.next();

int depth= locusInfo.getRecordAndPositions().size();

int pos= locusInfo.getPosition();

System.out.println("Depth " + depth + " at position " + pos);

}

samLocIter.close();
}
------------------------------------------------------------------------------
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to