Search in sources :

Example 1 with BreakendDirection

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());
                        }
                    }
                }
            }
        }
    }
}
Also used : TwoBitBufferedReferenceSequenceFile(au.edu.wehi.idsv.picard.TwoBitBufferedReferenceSequenceFile) InMemoryReferenceSequenceFile(au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile) BreakendDirection(au.edu.wehi.idsv.BreakendDirection) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary) Test(org.junit.Test)

Example 2 with BreakendDirection

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);
}
Also used : BreakendDirection(au.edu.wehi.idsv.BreakendDirection) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord)

Example 3 with BreakendDirection

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);
}
Also used : Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) BreakendDirection(au.edu.wehi.idsv.BreakendDirection) BreakendSummary(au.edu.wehi.idsv.BreakendSummary) BreakpointSummary(au.edu.wehi.idsv.BreakpointSummary)

Aggregations

BreakendDirection (au.edu.wehi.idsv.BreakendDirection)3 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)2 BreakpointSummary (au.edu.wehi.idsv.BreakpointSummary)2 Node (au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 TwoBitBufferedReferenceSequenceFile (au.edu.wehi.idsv.picard.TwoBitBufferedReferenceSequenceFile)1 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)1 Test (org.junit.Test)1