use of au.edu.wehi.idsv.BreakpointSummary in project gridss by PapenfussLab.
the class VariantCallingConfiguration method calculateBreakpointFilters.
public List<VcfFilter> calculateBreakpointFilters(VariantContextDirectedBreakpoint call) {
List<VcfFilter> filters = Lists.newArrayList();
BreakpointSummary bp = call.getBreakendSummary();
if (call.getEventSize() != null && call.getEventSize() < minSize) {
// over 90% of events are small. Since most SV analysis excludes such events
// we allow the default output
filters.add(VcfFilter.SMALL_EVENT);
}
if (bp.couldBeReferenceAllele() && call.getUntemplatedSequence().length() == 0) {
filters.add(VcfFilter.REFERENCE_ALLELE);
}
if (call.getBreakpointQual() < minScore || call.getBreakpointEvidenceCount() == 0) {
filters.add(VcfFilter.LOW_BREAKPOINT_SUPPORT);
}
if (call.getBreakpointEvidenceCountAssembly() == 0 && call.getBreakpointEvidenceCountReadPair() + call.getBreakpointEvidenceCountSoftClip() == 1) {
filters.add(VcfFilter.SINGLE_SUPPORT);
}
return filters;
}
use of au.edu.wehi.idsv.BreakpointSummary in project gridss by PapenfussLab.
the class Models method calculateBreakend.
/**
* Calculates the most likely breakend interval for the given evidence
* @param evidence
* @return breakend interval with highest total evidence quality
*/
public static BreakendSummary calculateBreakend(LinearGenomicCoordinate lgc, List<BreakendSummary> bs, List<Long> weights) {
if (bs == null || bs.size() == 0)
throw new IllegalArgumentException("No evidence supplied");
if (weights.size() != bs.size())
throw new IllegalArgumentException("Array lenght mismatch");
Node fwd = maximalInterval(lgc, BreakendDirection.Forward, bs, weights);
Node bwd = maximalInterval(lgc, BreakendDirection.Backward, bs, weights);
if (fwd == null && bwd == null) {
// all evidence is insignificant, just return something as we're going to get filtered anyway
BreakendSummary fallback = bs.get(0);
if (fallback instanceof BreakpointSummary) {
BreakpointSummary bp = (BreakpointSummary) fallback;
fallback = bp.localBreakend();
}
return fallback;
}
Node node = fwd;
BreakendDirection dir = BreakendDirection.Forward;
if (fwd == null || (bwd != null && fwd.weight < bwd.weight)) {
node = bwd;
dir = BreakendDirection.Backward;
}
assert (lgc.getReferenceIndex(node.start) == lgc.getReferenceIndex(node.stop));
int start = lgc.getReferencePosition(node.start);
int end = lgc.getReferencePosition(node.stop);
return new BreakendSummary(lgc.getReferenceIndex(node.start), dir, MathUtil.average(start, end), start, end);
}
use of au.edu.wehi.idsv.BreakpointSummary in project gridss by PapenfussLab.
the class SimulatedChromosome method assemble.
protected void assemble(File fasta, File vcf, List<Fragment> fragList, boolean includeReference) throws IOException {
StringBuilder sb = new StringBuilder();
if (includeReference) {
sb.append(">");
sb.append(getChr());
sb.append("\n");
sb.append(new String(seq, StandardCharsets.US_ASCII));
sb.append("\n");
}
sb.append(">chromothripsis." + getChr() + "\n");
List<IdsvVariantContext> calls = Lists.newArrayList();
Fragment last = null;
for (int i = 0; i < fragList.size(); i++) {
Fragment f = fragList.get(i);
sb.append(f.getSequence());
if (last != null) {
BreakpointSummary bp = new BreakpointSummary(last.getEndBreakend(), f.getStartBreakend());
String event = String.format("truth_%d_", i);
calls.add(create(bp, event).make());
calls.add(create(bp.remoteBreakpoint(), event).make());
}
last = f;
}
Collections.sort(calls, IdsvVariantContext.ByLocationStart);
Files.write(sb.toString(), fasta, StandardCharsets.US_ASCII);
VariantContextWriter writer = context.getVariantContextWriter(vcf, true);
for (VariantContext vc : calls) {
writer.add(vc);
}
writer.close();
}
use of au.edu.wehi.idsv.BreakpointSummary in project gridss by PapenfussLab.
the class AnnotateInexactHomologyTest method should_calculate_inexact_homology.
@Test
public void should_calculate_inexact_homology() {
ProcessingContext pc = getContext();
StructuralVariationCallBuilder builder = new StructuralVariationCallBuilder(pc, (VariantContextDirectedEvidence) new IdsvVariantContextBuilder(getContext()) {
{
breakpoint(new BreakpointSummary(2, FWD, 78, 6, BWD, 79), "");
phredScore(50);
}
}.make());
builder.addEvidence(SR(Read(2, 78, "1M1S"), Read(6, 79, "1M")));
VariantContextDirectedBreakpoint e = (VariantContextDirectedBreakpoint) builder.make();
AnnotateInexactHomology aih = new AnnotateInexactHomology();
aih.setContext(pc);
ExecutorService threadpool = Executors.newSingleThreadExecutor();
e = aih.iterator(new AutoClosingIterator<>(ImmutableList.of(e).iterator()), threadpool).next();
assertEquals(-78, ((int[]) e.getAttribute(VcfInfoAttributes.INEXACT_HOMPOS.attribute()))[0]);
assertEquals(300, ((int[]) e.getAttribute(VcfInfoAttributes.INEXACT_HOMPOS.attribute()))[1]);
threadpool.shutdown();
}
use of au.edu.wehi.idsv.BreakpointSummary in project gridss by PapenfussLab.
the class TruthAnnotatorTest method match_should_match_both_breakpoint_breakends.
@Test
public void match_should_match_both_breakpoint_breakends() {
assertTrue(TruthAnnotator.matches(new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), 0, 0));
assertTrue(TruthAnnotator.matches(new BreakpointSummary(new BreakendSummary(0, BWD, 10), new BreakendSummary(0, FWD, 1)), new BreakpointSummary(new BreakendSummary(0, FWD, 1), new BreakendSummary(0, BWD, 10)), 0, 0));
}
Aggregations