Search in sources :

Example 1 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 2 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 3 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 4 with IndexedSampleList

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

the class HaplotypeCallerEngine method initializeSamples.

private void initializeSamples() {
    sampleSet = ReadUtils.getSamplesFromHeader(readsHeader);
    samplesList = new IndexedSampleList(sampleSet);
    if (hcArgs.sampleNameToUse != null) {
        if (!sampleSet.contains(hcArgs.sampleNameToUse)) {
            throw new CommandLineException.BadArgumentValue("--sample_name", "Specified name does not exist in input bam files");
        }
        if (sampleSet.size() == 1) {
            //No reason to incur performance penalty associated with filtering if they specified the name of the only sample
            hcArgs.sampleNameToUse = null;
        } else {
            samplesList = new IndexedSampleList(hcArgs.sampleNameToUse);
            sampleSet.clear();
            sampleSet.add(hcArgs.sampleNameToUse);
        }
    }
}
Also used : IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList)

Example 5 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