def test_insert_grouped_itree(FakeGroupedITree, gene_intervals_short): tree = itree.GroupedITree(key="annotation") fake_tree = FakeGroupedITree(key="annotation", intervals=gene_intervals_short) for node in gene_intervals_short: tree.insert(node) assert tree.search(gene_intervals_short[0]) == \ fake_tree.search(gene_intervals_short[0])
def test_create_grouped_itree(gene_intervals_short): tree = itree.GroupedITree(key='annotation', intervals=gene_intervals_short) assert tree is not None expected = "GroupedITree(key=annotation, trees={'Chr10': ITree(root=(613874,621867))})" assert str(tree) == expected
def test_search_grouped_itree_string(FakeGroupedITree, gene_intervals_short): tree = itree.GroupedITree(key=lambda node: node.annotation, intervals=gene_intervals_short) assert tree is not None fake_tree = FakeGroupedITree(key=lambda node: node.annotation, intervals=gene_intervals_short) assert tree.search(gene_intervals_short[0]) == \ fake_tree.search(gene_intervals_short[0])
def test_remove_grouped_itree(FakeGroupedITree, gene_intervals_short): tree = itree.GroupedITree(key="annotation", intervals=gene_intervals_short) fake_tree = FakeGroupedITree(key="annotation", intervals=gene_intervals_short) tree.remove(gene_intervals_short[0]) fake_tree.remove(gene_intervals_short[0]) assert tree.search(gene_intervals_short[0]) == \ fake_tree.search(gene_intervals_short[0])
def test_search_grouped_itree_nonexistent_key(FakeNode, gene_intervals_short): tree = itree.GroupedITree(key='annotation', intervals=gene_intervals_short) assert tree is not None assert tree.search(FakeNode(1,2,annotation='IAMNOTANANNOTATION')) == []
def test_search_grouped_itree_callable(FakeGroupedITree, gene_intervals_short): tree = itree.GroupedITree(key='annotation', intervals=gene_intervals_short) assert tree is not None
def test_grouped_itree_non_string_non_callable_key(): with pytest.raises(TypeError): itree.GroupedITree(key=1)
def test_grouped_itree_too_short_key_signature(): with pytest.raises(TypeError): itree.GroupedITree(key=lambda: None)
def test_create_grouped_itree(gene_intervals_short): tree = itree.GroupedITree(key=lambda node: node.annotation, intervals=gene_intervals_short) assert tree is not None