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());
}
Aggregations