Search in sources :

Example 6 with IndexedSampleList

use of org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList in project gatk by broadinstitute.

the class CoverageUnitTest method testLikelihoodsEmpty.

@Test
public void testLikelihoodsEmpty() throws Exception {
    final List<GATKRead> reads = new ArrayList<>();
    final Map<String, List<GATKRead>> readsBySample = ImmutableMap.of("sample1", reads);
    final org.broadinstitute.hellbender.utils.genotyper.SampleList sampleList = new IndexedSampleList(Arrays.asList("sample1"));
    final AlleleList<Allele> alleleList = new IndexedAlleleList<>(Arrays.asList(Allele.NO_CALL));
    final ReadLikelihoods<Allele> likelihoods = new ReadLikelihoods<>(sampleList, alleleList, readsBySample);
    final VariantContext vc = makeVC();
    final ReferenceContext referenceContext = null;
    final Map<String, Object> annotate = new Coverage().annotate(referenceContext, vc, likelihoods);
    Assert.assertTrue(annotate.isEmpty());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) VariantContext(htsjdk.variant.variantcontext.VariantContext) IndexedAlleleList(org.broadinstitute.hellbender.utils.genotyper.IndexedAlleleList) ReadLikelihoods(org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods) Allele(htsjdk.variant.variantcontext.Allele) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) AlleleList(org.broadinstitute.hellbender.utils.genotyper.AlleleList) IndexedAlleleList(org.broadinstitute.hellbender.utils.genotyper.IndexedAlleleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 7 with IndexedSampleList

use of org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList in project gatk by broadinstitute.

the class HeterogeneousPloidyModelUnitTest method testPloidyAndSampleList.

@Test(dataProvider = "ploidyAndSampleListData")
public void testPloidyAndSampleList(final int[] ploidies) {
    final int sampleCount = ploidies.length;
    final List<String> sampleNames = new ArrayList<>(sampleCount);
    for (int i = 0; i < sampleCount; i++) sampleNames.add("SAMPLE_" + i);
    final IndexedSampleList sampleList = new IndexedSampleList(sampleNames);
    final PloidyModel ploidyModel = new HeterogeneousPloidyModel(sampleList, ploidies);
    final boolean expectedHom = allSame(ploidies);
    Assert.assertEquals(ploidyModel.isHomogeneous(), expectedHom);
    Assert.assertEquals(ploidyModel.totalPloidy(), MathUtils.sum(ploidies));
    for (int i = 0; i < sampleCount; i++) {
        Assert.assertEquals(ploidyModel.samplePloidy(i), ploidies[i]);
    }
    SampleListUnitTester.assertSampleList(ploidyModel, sampleNames);
}
Also used : ArrayList(java.util.ArrayList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Test(org.testng.annotations.Test)

Example 8 with IndexedSampleList

use of org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList in project gatk by broadinstitute.

the class HeterogeneousPloidyModelUnitTest method testBadLength.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testBadLength() throws Exception {
    final int sampleCount = 2;
    final List<String> sampleNames = new ArrayList<>(sampleCount);
    for (int i = 0; i < sampleCount; i++) sampleNames.add("SAMPLE_" + i);
    final IndexedSampleList sampleList = new IndexedSampleList(sampleNames);
    //count mismatch
    new HeterogeneousPloidyModel(sampleList, new int[] { 1, 2, 3 });
}
Also used : ArrayList(java.util.ArrayList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Test(org.testng.annotations.Test)

Example 9 with IndexedSampleList

use of org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList in project gatk by broadinstitute.

the class HomogeneousPloidyModelUnitTest method testPloidyAndSampleList.

@Test(dataProvider = "ploidyAndSampleListData")
public void testPloidyAndSampleList(final int ploidy, final int sampleCount) {
    final List<String> sampleNames = new ArrayList<>(sampleCount);
    for (int i = 0; i < sampleCount; i++) sampleNames.add("SAMPLE_" + i);
    final IndexedSampleList sampleList = new IndexedSampleList(sampleNames);
    final HomogeneousPloidyModel ploidyModel = new HomogeneousPloidyModel(sampleList, ploidy);
    Assert.assertTrue(ploidyModel.isHomogeneous());
    Assert.assertEquals(ploidyModel.totalPloidy(), sampleCount * ploidy);
    for (int i = 0; i < sampleCount; i++) Assert.assertEquals(ploidyModel.samplePloidy(i), ploidy);
    SampleListUnitTester.assertSampleList(ploidyModel, sampleNames);
}
Also used : ArrayList(java.util.ArrayList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Test(org.testng.annotations.Test)

Example 10 with IndexedSampleList

use of org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList in project gatk by broadinstitute.

the class Mutect2Engine method initialize.

private void initialize() {
    samplesList = new IndexedSampleList(new ArrayList<>(ReadUtils.getSamplesFromHeader(header)));
    if (!samplesList.asListOfSamples().contains(MTAC.tumorSampleName)) {
        throw new UserException.BadInput("BAM header sample names " + samplesList.asListOfSamples() + "does not contain given tumor" + " sample name " + MTAC.tumorSampleName);
    } else if (MTAC.normalSampleName != null && !samplesList.asListOfSamples().contains(MTAC.normalSampleName)) {
        throw new UserException.BadInput("BAM header sample names " + samplesList.asListOfSamples() + "does not contain given normal" + " sample name " + MTAC.normalSampleName);
    }
    annotationEngine = VariantAnnotatorEngine.ofSelectedMinusExcluded(MTAC.annotationGroupsToUse, MTAC.annotationsToUse, MTAC.annotationsToExclude, MTAC.dbsnp.dbsnp, MTAC.comps);
    assemblyEngine = AssemblyBasedCallerUtils.createReadThreadingAssembler(MTAC);
    likelihoodCalculationEngine = AssemblyBasedCallerUtils.createLikelihoodCalculationEngine(MTAC.likelihoodArgs);
    genotypingEngine = new SomaticGenotypingEngine(samplesList, MTAC, MTAC.tumorSampleName, MTAC.normalSampleName);
    genotypingEngine.setAnnotationEngine(annotationEngine);
    haplotypeBAMWriter = AssemblyBasedCallerUtils.createBamWriter(MTAC, header);
    trimmer.initialize(MTAC.assemblyRegionTrimmerArgs, header.getSequenceDictionary(), MTAC.debug, MTAC.genotypingOutputMode == GenotypingOutputMode.GENOTYPE_GIVEN_ALLELES, false);
    if (MTAC.CONTAMINATION_FRACTION_FILE != null) {
        MTAC.setSampleContamination(AlleleBiasedDownsamplingUtils.loadContaminationFile(MTAC.CONTAMINATION_FRACTION_FILE, MTAC.CONTAMINATION_FRACTION, samplesList.asSetOfSamples(), logger));
    }
}
Also used : IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) UserException(org.broadinstitute.hellbender.exceptions.UserException)

Aggregations

IndexedSampleList (org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList)21 Test (org.testng.annotations.Test)13 SampleList (org.broadinstitute.hellbender.utils.genotyper.SampleList)8 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)8 ArrayList (java.util.ArrayList)5 ReferenceContext (org.broadinstitute.hellbender.engine.ReferenceContext)4 AlleleList (org.broadinstitute.hellbender.utils.genotyper.AlleleList)4 IndexedAlleleList (org.broadinstitute.hellbender.utils.genotyper.IndexedAlleleList)4 ReadLikelihoods (org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods)4 Haplotype (org.broadinstitute.hellbender.utils.haplotype.Haplotype)4 List (java.util.List)3 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)3 Allele (htsjdk.variant.variantcontext.Allele)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 File (java.io.File)2 HashMap (java.util.HashMap)2 PairHMMNativeArguments (org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments)2 UserException (org.broadinstitute.hellbender.exceptions.UserException)2 AS_RMSMappingQuality (org.broadinstitute.hellbender.tools.walkers.annotator.allelespecific.AS_RMSMappingQuality)2 GeneralPloidyFailOverAFCalculatorProvider (org.broadinstitute.hellbender.tools.walkers.genotyper.afcalc.GeneralPloidyFailOverAFCalculatorProvider)2