use of au.edu.wehi.idsv.BreakendDirection in project gridss by PapenfussLab.
the class BreakpointHomologyTest method should_not_exceed_contig_bounds.
@Test
public void should_not_exceed_contig_bounds() {
InMemoryReferenceSequenceFile underlying = new InMemoryReferenceSequenceFile(new String[] { "0", "1" }, new byte[][] { B("CCCCCCCCCCC"), B("AAAAAAAAAAA") });
// BreakpointHomology bh0 = BreakpointHomology.calculate(ref, new BreakpointSummary(0, FWD, 1, 1, BWD, 20), "", 50, 50);
TwoBitBufferedReferenceSequenceFile ref = new TwoBitBufferedReferenceSequenceFile(underlying);
for (int b1pos = 1; b1pos <= ref.getSequenceDictionary().getSequences().get(0).getSequenceLength(); b1pos++) {
for (int b2pos = 1; b2pos <= ref.getSequenceDictionary().getSequences().get(0).getSequenceLength(); b2pos++) {
for (BreakendDirection b1dir : BreakendDirection.values()) {
for (BreakendDirection b2dir : BreakendDirection.values()) {
for (int maxBreakendLength = 1; maxBreakendLength < ref.getSequenceDictionary().getSequences().get(0).getSequenceLength() + 2; maxBreakendLength++) {
for (int margin = 0; margin < ref.getSequenceDictionary().getSequences().get(0).getSequenceLength() + 2; margin++) {
BreakpointHomology bh = BreakpointHomology.calculate(ref, new BreakpointSummary(0, b1dir, b1pos, 1, b2dir, b2pos), "", maxBreakendLength, margin);
assertEquals(0, bh.getLocalHomologyLength());
assertEquals(0, bh.getRemoteHomologyLength());
}
}
}
}
}
}
}
use of au.edu.wehi.idsv.BreakendDirection in project gridss by PapenfussLab.
the class BedpeRecord method parseBreakend.
private static BreakendSummary parseBreakend(SAMSequenceDictionary dict, String chr, String strStart, String strEnd, String strDirection, BreakendDirection defaultDirection) {
// convert back to 1-based
int start = Integer.parseInt(strStart) + 1;
int end = Integer.parseInt(strEnd);
BreakendDirection dir = defaultDirection;
if (strDirection.equals("+")) {
dir = BreakendDirection.Forward;
} else if (strDirection.equals("-")) {
dir = BreakendDirection.Backward;
}
SAMSequenceRecord seq = dict.getSequence(chr);
if (seq == null) {
throw new IllegalArgumentException(String.format("Contig %s missing from reference genome", chr));
}
return new BreakendSummary(seq.getSequenceIndex(), dir, (start + end) / 2, start, end);
}
use of au.edu.wehi.idsv.BreakendDirection 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);
}
Aggregations