Search in sources :

Example 16 with IndexedSampleList

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

the class HeterogeneousPloidyModelUnitTest method testBadPloidy.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testBadPloidy() 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);
    //bad ploidy
    new HeterogeneousPloidyModel(sampleList, new int[] { 1, -2 });
}
Also used : ArrayList(java.util.ArrayList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Test(org.testng.annotations.Test)

Example 17 with IndexedSampleList

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

the class OrientationBiasFilterer method createVCFHeader.

/** Ingest the current VCF header and update it with the information necessary for the Orientation Bias filter to run.
     *
     * @param inputVCFHeader original header.  Never {@code null}
     * @param commandLine The command line used to run this tool.
     * @param transitions  Never {@code null}
     * @return updated VCF Header
     */
public static VCFHeader createVCFHeader(final VCFHeader inputVCFHeader, final String commandLine, final List<String> transitions) {
    Utils.nonNull(inputVCFHeader);
    Utils.nonNull(transitions);
    // Setup header for output file
    final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputVCFHeader.getMetaDataInInputOrder());
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_FIELD_NAME, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Measure (across entire bam file) of orientation bias for a given REF/ALT error."));
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.PRE_ADAPTER_METRIC_RC_FIELD_NAME, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Measure (across entire bam file) of orientation bias for the complement of a given REF/ALT error."));
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.P_ARTIFACT_FIELD_NAME, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Orientation bias p value for the given REF/ALT artifact or its complement."));
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.FOB, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Fraction of alt reads indicating orientation bias error (taking into account artifact mode complement)."));
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_ARTIFACT_MODE, VCFHeaderLineCount.A, VCFHeaderLineType.String, "Whether the variant can be one of the given REF/ALT artifact modes."));
    headerLines.add(new VCFFormatHeaderLine(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_RC_ARTIFACT_MODE, VCFHeaderLineCount.A, VCFHeaderLineType.String, "Whether the variant can be one of the given REF/ALT artifact mode complements."));
    headerLines.add(new VCFFormatHeaderLine(VCFConstants.GENOTYPE_FILTER_KEY, 1, VCFHeaderLineType.String, "Genotype-level filter"));
    headerLines.add(new VCFFilterHeaderLine(OrientationBiasFilterConstants.IS_ORIENTATION_BIAS_CUT, "Orientation bias (in one of the specified artifact mode(s) or complement) seen in one or more samples."));
    headerLines.add(new VCFSimpleHeaderLine("orientation_bias_artifact_modes", String.join("|", transitions), "The artifact modes that were used for orientation bias artifact filtering for this VCF"));
    headerLines.add(new VCFHeaderLine("command", commandLine));
    final SampleList samples = new IndexedSampleList(inputVCFHeader.getGenotypeSamples());
    final Set<String> sampleNameSet = samples.asSetOfSamples();
    return new VCFHeader(headerLines, sampleNameSet);
}
Also used : IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList)

Example 18 with IndexedSampleList

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

the class PairHMMLikelihoodCalculationEngineUnitTest method testComputeLikelihoods.

@Test
public void testComputeLikelihoods() {
    final LikelihoodEngineArgumentCollection LEAC = new LikelihoodEngineArgumentCollection();
    PairHMMLikelihoodCalculationEngine.writeLikelihoodsToFile = true;
    final ReadLikelihoodCalculationEngine lce = new PairHMMLikelihoodCalculationEngine((byte) SAMUtils.MAX_PHRED_SCORE, new PairHMMNativeArguments(), PairHMM.Implementation.LOGLESS_CACHING, MathUtils.logToLog10(QualityUtils.qualToErrorProbLog10(LEAC.phredScaledGlobalReadMismappingRate)), PairHMMLikelihoodCalculationEngine.PCRErrorModel.CONSERVATIVE);
    final Map<String, List<GATKRead>> perSampleReadList = new HashMap<>();
    final int n = 10;
    final GATKRead read1 = ArtificialReadUtils.createArtificialRead(TextCigarCodec.decode(n + "M"));
    read1.setMappingQuality(60);
    final String sample1 = "sample1";
    perSampleReadList.put(sample1, Arrays.asList(read1));
    final SampleList samples = new IndexedSampleList(sample1);
    final AssemblyResultSet assemblyResultSet = new AssemblyResultSet();
    final byte[] bases = Strings.repeat("A", n + 1).getBytes();
    final Haplotype hap1 = new Haplotype(bases, true);
    hap1.setGenomeLocation(read1);
    assemblyResultSet.add(hap1);
    final byte[] basesModified = bases;
    //different bases
    basesModified[5] = 'C';
    final Haplotype hap2 = new Haplotype(basesModified, false);
    //use same loc
    hap2.setGenomeLocation(read1);
    assemblyResultSet.add(hap2);
    final ReadLikelihoods<Haplotype> likes = lce.computeReadLikelihoods(assemblyResultSet, samples, perSampleReadList);
    final LikelihoodMatrix<Haplotype> mtx = likes.sampleMatrix(0);
    Assert.assertEquals(mtx.numberOfAlleles(), 2);
    Assert.assertEquals(mtx.numberOfReads(), 1);
    final double v1 = mtx.get(0, 0);
    final double v2 = mtx.get(1, 0);
    Assert.assertTrue(v1 > v2, "matching haplotype should have a higher likelihood");
    lce.close();
    new File(PairHMMLikelihoodCalculationEngine.LIKELIHOODS_FILENAME).delete();
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) PairHMMNativeArguments(org.broadinstitute.gatk.nativebindings.pairhmm.PairHMMNativeArguments) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) File(java.io.File) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 19 with IndexedSampleList

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

the class RandomLikelihoodCalculationEngineUnitTest method testComputeLikelihoods.

@Test
public void testComputeLikelihoods() {
    final ReadLikelihoodCalculationEngine lce = new RandomLikelihoodCalculationEngine();
    final Map<String, List<GATKRead>> perSampleReadList = new HashMap<>();
    final int n = 10;
    final GATKRead read1 = ArtificialReadUtils.createArtificialRead(TextCigarCodec.decode(n + "M"));
    read1.setMappingQuality(60);
    final String sample1 = "sample1";
    perSampleReadList.put(sample1, Arrays.asList(read1));
    final SampleList samples = new IndexedSampleList(sample1);
    final AssemblyResultSet assemblyResultSet = new AssemblyResultSet();
    final byte[] bases = Strings.repeat("A", n + 1).getBytes();
    final Haplotype hap1 = new Haplotype(bases, true);
    hap1.setGenomeLocation(read1);
    assemblyResultSet.add(hap1);
    final byte[] basesModified = bases;
    //different bases
    basesModified[5] = 'C';
    final Haplotype hap2 = new Haplotype(basesModified, false);
    //use same loc
    hap2.setGenomeLocation(read1);
    assemblyResultSet.add(hap2);
    final ReadLikelihoods<Haplotype> likes = lce.computeReadLikelihoods(assemblyResultSet, samples, perSampleReadList);
    final LikelihoodMatrix<Haplotype> mtx = likes.sampleMatrix(0);
    Assert.assertEquals(mtx.numberOfAlleles(), 2);
    Assert.assertEquals(mtx.numberOfReads(), 1);
    final double v1 = mtx.get(0, 0);
    final double v2 = mtx.get(1, 0);
    Assert.assertTrue(v1 < 0);
    Assert.assertTrue(v2 < 0);
    lce.close();
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) HashMap(java.util.HashMap) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) List(java.util.List) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) Test(org.testng.annotations.Test)

Example 20 with IndexedSampleList

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

the class GenotypeGVCFs method onTraversalStart.

@Override
public void onTraversalStart() {
    final VCFHeader inputVCFHeader = getHeaderForVariants();
    if (onlyOutputCallsStartingInIntervals) {
        if (!hasIntervals()) {
            throw new CommandLineException.MissingArgument("-L or -XL", "Intervals are required if --" + ONLY_OUTPUT_CALLS_STARTING_IN_INTERVALS_FULL_NAME + " was specified.");
        }
    }
    intervals = hasIntervals() ? intervalArgumentCollection.getIntervals(getBestAvailableSequenceDictionary()) : Collections.emptyList();
    //todo should this be getSampleNamesInOrder?
    final SampleList samples = new IndexedSampleList(inputVCFHeader.getGenotypeSamples());
    genotypingEngine = new MinimalGenotypingEngine(createUAC(), samples, new GeneralPloidyFailOverAFCalculatorProvider(genotypeArgs));
    annotationEngine = VariantAnnotatorEngine.ofSelectedMinusExcluded(annotationGroupsToUse, annotationsToUse, annotationsToExclude, dbsnp.dbsnp, Collections.emptyList());
    merger = new ReferenceConfidenceVariantContextMerger();
    setupVCFWriter(inputVCFHeader, samples);
}
Also used : GeneralPloidyFailOverAFCalculatorProvider(org.broadinstitute.hellbender.tools.walkers.genotyper.afcalc.GeneralPloidyFailOverAFCalculatorProvider) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) IndexedSampleList(org.broadinstitute.hellbender.utils.genotyper.IndexedSampleList)

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