Search in sources :

Example 16 with TargetCollection

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

the class EvaluateCopyNumberTriStateCalls method processInterval.

/**
     * Processes a cluster of truth and called variants that may overlap over a genome region.
     * <p>
     * It returns the list of {@link VariantEvaluationContext} instances to be output for the given interval. These
     * are already sorted by coordinates.
     * </p>
     * @param truthReader reader to the truth variants.
     * @param callsReader reader to the called variants.
     * @param interval the interval to analyze.
     * @return never {@code null}.
     */
private List<VariantEvaluationContext> processInterval(final VCFFileReader truthReader, final VCFFileReader callsReader, final SimpleInterval interval, final TargetCollection<Target> targets) {
    final List<VariantContext> truthVariants = variantQueryToList(truthReader, interval);
    final List<VariantContext> callsVariants = variantQueryToList(callsReader, interval);
    final List<VariantEvaluationContext> evaluatedVariants = new ArrayList<>(truthVariants.size() + callsVariants.size());
    for (final VariantContext truth : truthVariants) {
        // skip truth that does not overlap a single target.
        if (targets.targetCount(truth) == 0) {
            continue;
        }
        final List<VariantContext> overlappingCalls = callsVariants.stream().filter(vc -> IntervalUtils.overlaps(truth, vc)).collect(Collectors.toList());
        evaluatedVariants.add(composeTruthOverlappingVariantContext(truth, overlappingCalls, targets));
    }
    for (final VariantContext call : callsVariants) {
        // skip call that does not overlap a single target (the user might want to call on a smaller set of targets)
        if (targets.targetCount(call) == 0) {
            continue;
        }
        final List<VariantContext> overlappingTruth = truthVariants.stream().filter(vc -> IntervalUtils.overlaps(call, vc)).collect(Collectors.toList());
        if (overlappingTruth.isEmpty()) {
            evaluatedVariants.add(composeNonTruthOverlappingVariantContext(call, targets));
        }
    }
    return evaluatedVariants.stream().sorted(IntervalUtils.LEXICOGRAPHICAL_ORDER_COMPARATOR).map(this::applyVariantContextFilters).collect(Collectors.toList());
}
Also used : Genotype(htsjdk.variant.variantcontext.Genotype) DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) Allele(htsjdk.variant.variantcontext.Allele) htsjdk.variant.vcf(htsjdk.variant.vcf) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) java.util(java.util) CopyNumberProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.CopyNumberProgramGroup) Argument(org.broadinstitute.barclay.argparser.Argument) VariantContextWriterBuilder(htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder) StandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions) ArgumentCollection(org.broadinstitute.barclay.argparser.ArgumentCollection) TargetArgumentCollection(org.broadinstitute.hellbender.tools.exome.TargetArgumentCollection) Function(java.util.function.Function) Pair(org.apache.commons.lang3.tuple.Pair) StreamSupport(java.util.stream.StreamSupport) TargetCollection(org.broadinstitute.hellbender.tools.exome.TargetCollection) org.broadinstitute.hellbender.utils(org.broadinstitute.hellbender.utils) Locatable(htsjdk.samtools.util.Locatable) CommandLineProgram(org.broadinstitute.hellbender.cmdline.CommandLineProgram) GenotypeBuilder(htsjdk.variant.variantcontext.GenotypeBuilder) IOException(java.io.IOException) CopyNumberTriStateAllele(org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriStateAllele) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) File(java.io.File) HMMPostProcessor(org.broadinstitute.hellbender.utils.hmm.segmentation.HMMPostProcessor) XHMMSegmentGenotyper(org.broadinstitute.hellbender.tools.exome.germlinehmm.xhmm.XHMMSegmentGenotyper) Stream(java.util.stream.Stream) UserException(org.broadinstitute.hellbender.exceptions.UserException) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) Target(org.broadinstitute.hellbender.tools.exome.Target) XHMMSegmentCaller(org.broadinstitute.hellbender.tools.exome.germlinehmm.xhmm.XHMMSegmentCaller) VariantContext(htsjdk.variant.variantcontext.VariantContext) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) VariantContext(htsjdk.variant.variantcontext.VariantContext)

Aggregations

File (java.io.File)16 java.util (java.util)16 Collectors (java.util.stream.Collectors)16 Argument (org.broadinstitute.barclay.argparser.Argument)16 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)16 TargetCollection (org.broadinstitute.hellbender.tools.exome.TargetCollection)16 Allele (htsjdk.variant.variantcontext.Allele)14 Genotype (htsjdk.variant.variantcontext.Genotype)14 VariantContext (htsjdk.variant.variantcontext.VariantContext)14 IOException (java.io.IOException)14 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)14 Pair (org.apache.commons.lang3.tuple.Pair)14 Target (org.broadinstitute.hellbender.tools.exome.Target)14 TargetArgumentCollection (org.broadinstitute.hellbender.tools.exome.TargetArgumentCollection)14 CopyNumberTriStateAllele (org.broadinstitute.hellbender.tools.exome.germlinehmm.CopyNumberTriStateAllele)14 XHMMSegmentGenotyper (org.broadinstitute.hellbender.tools.exome.germlinehmm.xhmm.XHMMSegmentGenotyper)14 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)10 CommandLineProgram (org.broadinstitute.hellbender.cmdline.CommandLineProgram)10 Locatable (htsjdk.samtools.util.Locatable)8 GenotypeBuilder (htsjdk.variant.variantcontext.GenotypeBuilder)8