use of au.edu.wehi.idsv.VariantContextDirectedEvidence in project gridss by PapenfussLab.
the class ComputeCoverage method initIntervalCoverageAccumulator.
private IntervalCoverageAccumulator initIntervalCoverageAccumulator() {
SAMSequenceDictionary dictionary = getReference().getSequenceDictionary();
if (VCF == null) {
return new IntervalCoverageAccumulator(COVERAGE_METHOD, dictionary, BIN_SIZE, null);
} else {
try (VCFFileReader vcfReader = new VCFFileReader(VCF, false)) {
try (CloseableIterator<VariantContext> it = vcfReader.iterator()) {
GenomicProcessingContext pc = new GenomicProcessingContext(new FileSystemContext(TMP_DIR.get(0), MAX_RECORDS_IN_RAM), REFERENCE_SEQUENCE, getReference());
Iterator<IdsvVariantContext> idsvIt = Iterators.transform(it, variant -> IdsvVariantContext.create(pc, null, variant));
Iterator<VariantContextDirectedEvidence> bpit = Iterators.filter(idsvIt, VariantContextDirectedEvidence.class);
return new IntervalCoverageAccumulator(COVERAGE_METHOD, dictionary, BIN_SIZE, bpit);
}
}
}
}
use of au.edu.wehi.idsv.VariantContextDirectedEvidence in project gridss by PapenfussLab.
the class TruthAnnotator method annotate.
public VariantContextDirectedEvidence annotate(VariantContextDirectedEvidence variant) {
BreakendSummary variantBreakend = variant.getBreakendSummary();
BreakpointSummary variantBreakpoint = null;
if (variantBreakend instanceof BreakpointSummary) {
variantBreakpoint = (BreakpointSummary) variantBreakend;
variantBreakend = variantBreakpoint.localBreakend();
}
HashSet<String> breakpointHits = Sets.newHashSet();
HashSet<String> breakendHits = Sets.newHashSet();
for (IdsvVariantContext truthVariant : truth) {
if ((truthVariant.hasAttribute(VcfSvConstants.SV_TYPE_KEY) && truthVariant.getAttributeAsString(VcfSvConstants.SV_TYPE_KEY, "").equals("INS")) || (truthVariant.hasAttribute(VcfSvConstants.SV_TYPE_KEY) && truthVariant.getAttributeAsString(VcfSvConstants.SV_TYPE_KEY, "").equals("DEL"))) {
int svLen = truthVariant.getAttributeAsInt(VcfSvConstants.SV_LENGTH_KEY, 0);
int untemplatedSequence = 0;
if (variant instanceof VariantContextDirectedEvidence) {
untemplatedSequence = ((VariantContextDirectedEvidence) variant).getBreakendSequence().length;
}
// two breakpoints: forward & backward
BreakendSummary truthBreakendStart = new BreakendSummary(truthVariant.getReferenceIndex(), BreakendDirection.Forward, truthVariant.getStart());
int endOffset = Math.max(0, -truthVariant.getAttributeAsInt(VcfSvConstants.SV_LENGTH_KEY, 0));
endOffset = truthVariant.getStart() + endOffset + 1;
BreakendSummary truthBreakendEnd = new BreakendSummary(truthVariant.getReferenceIndex(), BreakendDirection.Backward, endOffset);
BreakpointSummary truthBreakpoint = new BreakpointSummary(truthBreakendStart, truthBreakendEnd);
if (matches(truthBreakpoint, variantBreakpoint, svLen, untemplatedSequence)) {
breakpointHits.add(truthVariant.getID());
} else if (matches(truthBreakpoint, variantBreakend, svLen, untemplatedSequence)) {
breakendHits.add(truthVariant.getID());
}
} else {
throw new RuntimeException(String.format("Matching of truth variant at %s:%d not yet implemented.", truthVariant.getContig(), truthVariant.getStart()));
}
}
if (!breakpointHits.isEmpty() || !breakendHits.isEmpty()) {
IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(processContext, variant);
builder.attribute("TRUTH_MATCHES", Lists.newArrayList(breakpointHits));
builder.attribute("TRUTH_MISREALIGN", Lists.newArrayList(breakendHits));
return (VariantContextDirectedEvidence) builder.make();
}
return variant;
}
Aggregations