Ejemplo n.º 1
0
    def test_all_filter(self):
        graph = BELGraph()
        graph.add_increases(Protein(n(), n()),
                            Protein(n(), n()),
                            citation=n(),
                            evidence=n(),
                            annotations={'A': {'1', '2', '3'}})

        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1'}})))
        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1', '2'}})))
        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1', '2',
                                                               '3'}})))
        self.assertEqual(
            0,
            count_passed_edge_filter(
                graph,
                build_annotation_dict_all_filter({'A': {'1', '2', '3', '4'}})))
        self.assertEqual(
            0,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'4'}})))
Ejemplo n.º 2
0
    def test_all_filter(self):
        graph = BELGraph()
        graph.add_edge(1, 2, annotations={'A': {'1', '2', '3'}})

        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1'}})))
        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1', '2'}})))
        self.assertEqual(
            1,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'1', '2',
                                                               '3'}})))
        self.assertEqual(
            0,
            count_passed_edge_filter(
                graph,
                build_annotation_dict_all_filter({'A': {'1', '2', '3', '4'}})))
        self.assertEqual(
            0,
            count_passed_edge_filter(
                graph, build_annotation_dict_all_filter({'A': {'4'}})))
Ejemplo n.º 3
0
 def test_all_filter_no_annotations(self):
     graph = BELGraph()
     graph.add_increases(protein(n(), n()), protein(n(), n()), n(), n())
     self.assertEqual(
         0,
         count_passed_edge_filter(
             graph, build_annotation_dict_all_filter({'A': {'1'}})))
Ejemplo n.º 4
0
 def test_all_filter_no_query(self):
     """Test that the all filter returns true when there's no argument"""
     graph = BELGraph()
     graph.add_increases(protein(n(), n()), protein(n(), n()), n(), n())
     self.assertEqual(
         1,
         count_passed_edge_filter(graph,
                                  build_annotation_dict_all_filter({})))
Ejemplo n.º 5
0
    def test_all_filter_dict(self):
        graph = BELGraph()
        graph.annotation_list['A'] = set('12345')
        a, b = Protein(namespace='hgnc', identifier='1', name='A'), Protein(namespace='hgnc', identifier='2', name='B')
        graph.add_increases(a, b, citation=n(), evidence=n(), annotations={
            'A': {'1', '2', '3'},
        })

        self.assertEqual(1, count_passed_edge_filter(graph, build_annotation_dict_all_filter(graph._clean_annotations({'A': {'1': True}}))))
        self.assertEqual(1, count_passed_edge_filter(graph, build_annotation_dict_all_filter(graph._clean_annotations({
            'A': {'1': True, '2': True}
        }))))
        self.assertEqual(1, count_passed_edge_filter(graph, build_annotation_dict_all_filter(graph._clean_annotations({
            'A': {'1': True, '2': True, '3': True}
        }))))
        self.assertEqual(0, count_passed_edge_filter(graph, build_annotation_dict_all_filter(graph._clean_annotations({
            'A': {'1': True, '2': True, '3': True, '4': True}
        }))))
        self.assertEqual(0, count_passed_edge_filter(graph, build_annotation_dict_all_filter(graph._clean_annotations({
            'A': {'4': True}
        }))))