示例#1
0
    def simple_test():
        graph = Graph({
            1: Block(10),
            2: Block(1),
            3: Block(1),
            4: Block(10)
        }, {
            1: [2, 3],
            2: [4],
            3: [4]
        })
        graph.convert_to_numpy_backend()

        sequence_graph = SequenceGraph.create_empty_from_ob_graph(graph)
        sequence_graph.set_sequence(1, "GGGTTTATAC")
        sequence_graph.set_sequence(2, "A")
        sequence_graph.set_sequence(3, "C")
        sequence_graph.set_sequence(4, "GTACATTGTA")

        linear_ref = Interval(0, 10, [1, 2, 3], graph)
        linear_ref = linear_ref.to_numpy_indexed_interval()

        critical_nodes = set([4])

        finder = MinimizerFinder(graph,
                                 sequence_graph,
                                 critical_nodes,
                                 linear_ref,
                                 k=3,
                                 w=3)
        minimizers = finder.find_minimizers()
        assert minimizers.has_minimizer(2, 0)
        assert minimizers.has_minimizer(3, 0)
        assert minimizers.has_minimizer(4, 4)
示例#2
0
def test_reverse():
    graph = Graph({
        1: Block(10),
        2: Block(5),
        3: Block(10),
        4: Block(5)
    }, {
        1: [2, 3],
        2: [4],
        3: [4]
    })
    graph.convert_to_numpy_backend()
    linear_path = NumpyIndexedInterval.from_interval(
        Interval(0, 10, [1, 2, 4], graph))
    alignments = [Interval(4, 5, [-3, -1], graph)]
    projected = project_alignments(alignments, linear_path)
    projected = list(projected)
    assert projected[0] == (5, 16, "-")
示例#3
0
    def test_many_nodes():
        nodes = {i: Block(1) for i in range(2, 10)}
        nodes[1] = Block(10)
        nodes[10] = Block(10)

        graph = Graph(
            nodes, {
                1: [2, 3],
                2: [4],
                3: [4],
                4: [5, 6],
                5: [7],
                6: [7],
                7: [8, 9],
                8: [10],
                9: [10]
            })

        graph.convert_to_numpy_backend()
        sequence_graph = SequenceGraph.create_empty_from_ob_graph(graph)
        sequence_graph.set_sequence(1, "ACTGACTGAC")
        sequence_graph.set_sequence(10, "ACTGACTGAC")
        sequence_graph.set_sequence(2, "A")
        sequence_graph.set_sequence(3, "C")
        sequence_graph.set_sequence(4, "A")
        sequence_graph.set_sequence(5, "G")
        sequence_graph.set_sequence(6, "C")
        sequence_graph.set_sequence(7, "T")
        sequence_graph.set_sequence(8, "A")
        sequence_graph.set_sequence(9, "A")

        linear_ref = Interval(0, 10, [1, 2, 4, 6, 7, 8, 10], graph)
        linear_ref = linear_ref.to_numpy_indexed_interval()
        critical_nodes = {1, 4, 7, 10}

        finder = MinimizerFinder(graph,
                                 sequence_graph,
                                 critical_nodes,
                                 linear_ref,
                                 k=3,
                                 w=3)
        minimizers = finder.find_minimizers()
        print(len(minimizers.minimizers))
示例#4
0
def test_simple():
    graph = Graph({
        1: Block(10),
        2: Block(5),
        3: Block(10),
        4: Block(5)
    }, {
        1: [2, 3],
        2: [4],
        3: [4]
    })
    graph.convert_to_numpy_backend()
    linear_path = NumpyIndexedInterval.from_interval(
        Interval(0, 10, [1, 2, 4], graph))
    alignments = [Interval(5, 5, [1, 3], graph), Interval(5, 5, [3, 4], graph)]
    projected = project_alignments(alignments, linear_path)
    projected = list(projected)
    assert projected[0] == (5, 15, "+")
    assert projected[1] == (15, 25, "+")
示例#5
0
def test_many_nodes():
    nodes = {i: Block(1) for i in range(2, 10)}
    nodes[1] = Block(10)
    nodes[10] = Block(10)

    graph = Graph(
        nodes, {
            1: [2, 3],
            2: [4],
            3: [4],
            4: [5, 6],
            5: [7],
            6: [7],
            7: [8, 9],
            8: [10],
            9: [10]
        })

    graph.convert_to_numpy_backend()
    sequence_graph = SequenceGraph.create_empty_from_ob_graph(graph)
    sequence_graph.set_sequence(1, "ACTGACTGAC")
    sequence_graph.set_sequence(10, "ACTGACTGAC")
    sequence_graph.set_sequence(2, "A")
    sequence_graph.set_sequence(3, "C")
    sequence_graph.set_sequence(4, "A")
    sequence_graph.set_sequence(5, "G")
    sequence_graph.set_sequence(6, "C")
    sequence_graph.set_sequence(7, "T")
    sequence_graph.set_sequence(8, "T")
    sequence_graph.set_sequence(9, "A")

    linear_ref_nodes = {1, 2, 4, 6, 7, 8, 10}
    read_sequence = "ACTGACCAGTAACTGAC"
    start_node = 1
    start_offset = 4
    aligner = LocalGraphAligner(graph, sequence_graph, read_sequence,
                                linear_ref_nodes, start_node, start_offset)
    alignment, score = aligner.align()
    assert alignment == [1, 3, 4, 5, 7, 9, 10]