Search in sources :

Example 11 with CopyNumberTriState

use of org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState in project gatk 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());
    }
}
Also used : IndexRange(org.broadinstitute.hellbender.utils.IndexRange) Target(org.broadinstitute.hellbender.tools.exome.Target) CopyNumberTriState(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState)

Example 12 with CopyNumberTriState

use of org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState in project gatk by broadinstitute.

the class XHMMSegmentCallerIntegrationTest method assertSampleSegmentsCoverAllTargets.

private void assertSampleSegmentsCoverAllTargets(final List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> sampleRecords, final TargetCollection<Target> targets) {
    int next = 0;
    for (final HiddenStateSegmentRecord<CopyNumberTriState, Target> record : sampleRecords) {
        final IndexRange range = targets.indexRange(record.getSegment());
        Assert.assertEquals(range.from, next);
        next = range.to;
    }
}
Also used : IndexRange(org.broadinstitute.hellbender.utils.IndexRange) Target(org.broadinstitute.hellbender.tools.exome.Target) CopyNumberTriState(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState)

Example 13 with CopyNumberTriState

use of org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState in project gatk 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);
    }
}
Also used : IndexRange(org.broadinstitute.hellbender.utils.IndexRange) Target(org.broadinstitute.hellbender.tools.exome.Target) CopyNumberTriState(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState)

Example 14 with CopyNumberTriState

use of org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState in project gatk 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());
    }
}
Also used : IndexRange(org.broadinstitute.hellbender.utils.IndexRange) Target(org.broadinstitute.hellbender.tools.exome.Target) CopyNumberTriState(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState)

Example 15 with CopyNumberTriState

use of org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState in project gatk by broadinstitute.

the class XHMMSegmentGenotyperIntegrationTest method assertVariantsAreCoveredBySegments.

private void assertVariantsAreCoveredBySegments(final List<VariantContext> variants, final List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> variantSegments) {
    for (final VariantContext variant : variants) {
        final List<HiddenStateSegmentRecord<CopyNumberTriState, Target>> matches = variantSegments.stream().filter(s -> new SimpleInterval(variant).equals(s.getSegment().getInterval())).collect(Collectors.toList());
        Assert.assertFalse(matches.isEmpty());
        for (final Genotype genotype : variant.getGenotypes()) {
            final boolean discovery = genotype.getExtendedAttribute(XHMMSegmentGenotyper.DISCOVERY_KEY).toString().equals(XHMMSegmentGenotyper.DISCOVERY_TRUE);
            if (discovery) {
                Assert.assertTrue(matches.stream().anyMatch(s -> s.getSampleName().equals(genotype.getSampleName())));
            } else {
                Assert.assertTrue(matches.stream().noneMatch(s -> s.getSampleName().equals(genotype.getSampleName())));
            }
        }
    }
}
Also used : Genotype(htsjdk.variant.variantcontext.Genotype) HiddenStateSegmentRecord(org.broadinstitute.hellbender.utils.hmm.segmentation.HiddenStateSegmentRecord) IntStream(java.util.stream.IntStream) Allele(htsjdk.variant.variantcontext.Allele) htsjdk.variant.vcf(htsjdk.variant.vcf) java.util(java.util) GATKProtectedMathUtils(org.broadinstitute.hellbender.utils.GATKProtectedMathUtils) DataProvider(org.testng.annotations.DataProvider) StandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions) QualityUtils(org.broadinstitute.hellbender.utils.QualityUtils) Test(org.testng.annotations.Test) IOException(java.io.IOException) TargetArgumentCollection(org.broadinstitute.hellbender.tools.exome.TargetArgumentCollection) CopyNumberTriStateAllele(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriStateAllele) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) HMMPostProcessor(org.broadinstitute.hellbender.utils.hmm.segmentation.HMMPostProcessor) Assert(org.testng.Assert) Target(org.broadinstitute.hellbender.tools.exome.Target) CopyNumberTriState(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState) VariantContext(htsjdk.variant.variantcontext.VariantContext) HiddenStateSegmentRecordReader(org.broadinstitute.hellbender.utils.hmm.segmentation.HiddenStateSegmentRecordReader) VariantContext(htsjdk.variant.variantcontext.VariantContext) HiddenStateSegmentRecord(org.broadinstitute.hellbender.utils.hmm.segmentation.HiddenStateSegmentRecord) Genotype(htsjdk.variant.variantcontext.Genotype) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval)

Aggregations

CopyNumberTriState (org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriState)24 Target (org.broadinstitute.hellbender.tools.exome.Target)20 HiddenStateSegmentRecord (org.broadinstitute.hellbender.utils.hmm.segmentation.HiddenStateSegmentRecord)10 Test (org.testng.annotations.Test)10 Genotype (htsjdk.variant.variantcontext.Genotype)8 IndexRange (org.broadinstitute.hellbender.utils.IndexRange)8 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)8 Allele (htsjdk.variant.variantcontext.Allele)6 File (java.io.File)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 htsjdk.variant.vcf (htsjdk.variant.vcf)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 IntStream (java.util.stream.IntStream)4 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)4 TargetArgumentCollection (org.broadinstitute.hellbender.tools.exome.TargetArgumentCollection)4 CopyNumberTriStateAllele (org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriStateAllele)4 CopyNumberTriStateTransitionProbabilityCache (org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriStateTransitionProbabilityCache)4