use of org.broadinstitute.hellbender.utils.IndexRange in project gatk by broadinstitute.
the class AlleleFrequencyCalculator method log10NormalizedGenotypePosteriors.
private static double[] log10NormalizedGenotypePosteriors(final Genotype g, final GenotypeLikelihoodCalculator glCalc, final double[] log10AlleleFrequencies) {
final double[] log10Likelihoods = g.getLikelihoods().getAsVector();
final double[] log10Posteriors = new IndexRange(0, glCalc.genotypeCount()).mapToDouble(genotypeIndex -> {
final GenotypeAlleleCounts gac = glCalc.genotypeAlleleCountsAt(genotypeIndex);
return gac.log10CombinationCount() + log10Likelihoods[genotypeIndex] + gac.sumOverAlleleIndicesAndCounts((index, count) -> count * log10AlleleFrequencies[index]);
});
return MathUtils.normalizeLog10(log10Posteriors);
}
use of org.broadinstitute.hellbender.utils.IndexRange in project gatk by broadinstitute.
the class HashedListTargetCollectionUnitTest method testEmptyRangeObject.
@Test(dependsOnMethods = { "testCorrectInitialization", "testCorrectRangeObjectInitialization" })
public void testEmptyRangeObject() {
final IndexRange range = new IndexRange(0, 0);
final List<SimpleInterval> targets = targetDB.targets(range);
Assert.assertNotNull(targets);
Assert.assertEquals(targets.size(), 0);
}
use of org.broadinstitute.hellbender.utils.IndexRange in project gatk-protected by broadinstitute.
the class XHMMSegmentCallerIntegrationTest method assertOutputIsInOrder.
private void assertOutputIsInOrder(final List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> outputRecords, final TargetCollection<Target> targets) {
for (int i = 1; i < outputRecords.size(); i++) {
final HiddenStateSegmentRecord<CopyNumberTriState, Target> nextRecord = outputRecords.get(i);
final HiddenStateSegmentRecord<CopyNumberTriState, Target> previousRecord = outputRecords.get(i - 1);
final IndexRange nextRange = targets.indexRange(nextRecord.getSegment());
final IndexRange previousRange = targets.indexRange(previousRecord.getSegment());
Assert.assertTrue(nextRange.from >= previousRange.from);
}
}
use of org.broadinstitute.hellbender.utils.IndexRange in project gatk-protected by broadinstitute.
the class XHMMSegmentCallerIntegrationTest method assertSampleSegmentsCoordinates.
private void assertSampleSegmentsCoordinates(List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> sampleRecords, TargetCollection<Target> targets) {
for (final HiddenStateSegmentRecord<CopyNumberTriState, Target> record : sampleRecords) {
final IndexRange range = targets.indexRange(record.getSegment());
Assert.assertTrue(range.size() > 0);
Assert.assertEquals(record.getSegment().getContig(), targets.location(range.from).getContig());
Assert.assertEquals(record.getSegment().getStart(), targets.location(range.from).getStart());
Assert.assertEquals(record.getSegment().getEnd(), targets.location(range.to - 1).getEnd());
}
}
use of org.broadinstitute.hellbender.utils.IndexRange in project gatk-protected by broadinstitute.
the class XHMMSegmentCallerIntegrationTest method assertOutputHasConsistentNumberOfTargets.
private void assertOutputHasConsistentNumberOfTargets(final List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> outputRecords, final TargetCollection<Target> targets) {
for (final HiddenStateSegmentRecord<CopyNumberTriState, Target> nextRecord : outputRecords) {
final IndexRange indexRange = targets.indexRange(nextRecord.getSegment());
Assert.assertEquals(indexRange.to - indexRange.from, nextRecord.getSegment().getTargetCount());
}
}
Aggregations