Search in sources :

Example 1 with Node

use of au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node in project gridss by PapenfussLab.

the class MaximumCliqueIntervalGraphTest method should_return_best_scoring_clique.

@Test
public void should_return_best_scoring_clique() {
    List<Node> nodes = new ArrayList<Node>();
    nodes.add(new Node(1, 2, 1));
    nodes.add(new Node(2, 3, 1));
    nodes.add(new Node(3, 4, 2));
    nodes.add(new Node(4, 5, 1));
    nodes.add(new Node(5, 6, 1));
    nodes.add(new Node(4, 10, 1));
    Node result = new MaximumCliqueIntervalGraph().calculateMaximumClique(nodes);
    assertEquals(4L, result.start);
    assertEquals(4L, result.stop);
    assertEquals(4L, result.weight);
    nodes = new ArrayList<Node>();
    nodes.add(new Node(10, 15, 1));
    nodes.add(new Node(15, 18, 1));
    nodes.add(new Node(17, 18, 1));
    nodes.add(new Node(9, 15, 1));
    nodes.add(new Node(19, 20, 1));
    nodes.add(new Node(19, 21, 1));
    result = new MaximumCliqueIntervalGraph().calculateMaximumClique(nodes);
    assertEquals(15, result.start);
    assertEquals(15, result.stop);
    assertEquals(3, result.weight);
}
Also used : Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with Node

use of au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node in project gridss by PapenfussLab.

the class MaximumCliqueIntervalGraphTest method should_incorporate_node_weight.

@Test
public void should_incorporate_node_weight() {
    List<Node> nodes = new ArrayList<Node>();
    nodes.add(new Node(1, 2, 3));
    nodes.add(new Node(3, 4, 1));
    nodes.add(new Node(3, 4, 1));
    Node result = new MaximumCliqueIntervalGraph().calculateMaximumClique(nodes);
    assertEquals(1L, result.start);
    assertEquals(2L, result.stop);
    assertEquals(3L, result.weight);
}
Also used : Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with Node

use of au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node 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)

Example 4 with Node

use of au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node in project gridss by PapenfussLab.

the class Models method maximalInterval.

private static Node maximalInterval(LinearGenomicCoordinate lgc, BreakendDirection dir, List<BreakendSummary> breaks, List<Long> weights) {
    MaximumCliqueIntervalGraph calc = new MaximumCliqueIntervalGraph();
    List<Node> nodes = new ArrayList<Node>(breaks.size());
    for (int i = 0; i < breaks.size(); i++) {
        BreakendSummary bs = breaks.get(i);
        long weight = weights.get(i);
        if (bs == null)
            continue;
        if (bs.direction != dir)
            continue;
        if (weight > 0) {
            nodes.add(new Node(lgc.getLinearCoordinate(bs.referenceIndex, bs.start), lgc.getLinearCoordinate(bs.referenceIndex, bs.end), weight));
        }
    }
    if (nodes.size() == 0)
        return null;
    return calc.calculateMaximumClique(nodes);
}
Also used : MaximumCliqueIntervalGraph(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph) Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) ArrayList(java.util.ArrayList) BreakendSummary(au.edu.wehi.idsv.BreakendSummary)

Example 5 with Node

use of au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node in project gridss by PapenfussLab.

the class MaximumCliqueIntervalGraphTest method should_return_lowest_position_best_score.

@Test
public void should_return_lowest_position_best_score() {
    List<Node> nodes = new ArrayList<Node>();
    nodes.add(new Node(1, 2, 1));
    nodes.add(new Node(2, 3, 1));
    nodes.add(new Node(3, 4, 1));
    nodes.add(new Node(4, 5, 1));
    nodes.add(new Node(5, 6, 1));
    Node result = new MaximumCliqueIntervalGraph().calculateMaximumClique(nodes);
    assertEquals(2L, result.start);
    assertEquals(2L, result.stop);
    assertEquals(2L, result.weight);
}
Also used : Node(au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Node (au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph.Node)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 BreakendSummary (au.edu.wehi.idsv.BreakendSummary)2 BreakendDirection (au.edu.wehi.idsv.BreakendDirection)1 BreakpointSummary (au.edu.wehi.idsv.BreakpointSummary)1 MaximumCliqueIntervalGraph (au.edu.wehi.idsv.graph.MaximumCliqueIntervalGraph)1