Пример #1
0
    def setUp(self):
        super().setUp()

        graph = BELGraph(name='test', version='0.0.0')
        graph.annotation_list['TEST'] = {'a', 'b', 'c'}

        graph.add_positive_correlation(
            mirna_1,
            pathology_1,
            evidence=n(),
            citation=n(),
        )

        graph.add_negative_correlation(
            mirna_2,
            pathology_1,
            evidence=n(),
            citation=n(),
        )

        make_dummy_namespaces(self.manager, graph)
        make_dummy_annotations(self.manager, graph)

        with mock_bel_resources:
            self.manager.insert_graph(graph)
Пример #2
0
    def test_subject_activity_default(self, mock):
        p1_name = n()
        p2_name = n()

        self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'),
                                 Protein(name=p2_name, namespace='HGNC'),
                                 evidence=n(),
                                 citation=n(),
                                 subject_modifier=activity('kin'))

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count(), msg='number of nodes')
        self.assertEqual(1, network.edges.count(), msg='number of edges')

        kin_list = self.manager.session.query(NamespaceEntry).filter(
            NamespaceEntry.name == 'kin').all()
        self.assertEqual(1,
                         len(kin_list),
                         msg='number of kinase NamespaceEntrys')

        kin = list(kin_list)[0]
        self.assertEqual('kin', kin.name)

        effects = self.manager.session.query(Property).join(
            NamespaceEntry).filter(Property.effect == kin)
        self.assertEqual(1, effects.count(), msg='number of effects')
Пример #3
0
    def test_mixed_2(self):
        """Tests both subject and object activity with location information as well."""
        self.graph.add_directly_increases(
            Protein(namespace='HGNC', name='HDAC4'),
            Protein(namespace='HGNC', name='MEF2A'),
            citation='10487761',
            evidence=
            """"In the nucleus, HDAC4 associates with the myocyte enhancer factor MEF2A. Binding of HDAC4 to
        MEF2A results in the repression of MEF2A transcriptional activation, a function that requires the
        deacetylase domain of HDAC4.""",
            annotations={'Species': '9606'},
            subject_modifier=activity('cat',
                                      location=Entity(namespace='GO',
                                                      name='nucleus')),
            object_modifier=activity('tscript',
                                     location=Entity(namespace='GO',
                                                     name='nucleus')))

        make_dummy_namespaces(self.manager, self.graph)
        make_dummy_annotations(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        edge = network.edges.first()
        self.assertEqual(4, edge.properties.count())
        self.assertEqual(2,
                         edge.properties.filter(Property.is_subject).count())
        self.assertEqual(
            2,
            edge.properties.filter(not_(Property.is_subject)).count())
Пример #4
0
    def test_object_activity_custom(self, mock):
        p1_name = n()
        p2_name = n()
        dummy_activity_namespace = n()
        dummy_activity_name = n()

        self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'),
                                 Protein(name=p2_name, namespace='HGNC'),
                                 evidence=n(),
                                 citation=n(),
                                 object_modifier=activity(
                                     name=dummy_activity_name,
                                     namespace=dummy_activity_namespace))

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        kin_list = self.manager.session.query(NamespaceEntry).filter(
            NamespaceEntry.name == dummy_activity_name).all()
        self.assertEqual(1, len(kin_list))

        kin = list(kin_list)[0]
        self.assertEqual(dummy_activity_name, kin.name)

        effects = self.manager.session.query(Property).join(
            NamespaceEntry).filter(Property.effect == kin)
        self.assertEqual(1, effects.count())
Пример #5
0
    def test_simple(self, mock):
        """This test checks that the network can be added and dropped"""
        graph = BELGraph(name='test', version='0.0.0')

        namespaces = {'HGNC': ['YFG1', 'YFG2']}
        annotations = {'Disease': ['Disease1', 'Disease2'], 'Cell': ['Cell1']}

        make_dummy_namespaces(self.manager, graph, namespaces)
        make_dummy_annotations(self.manager, graph, annotations)

        graph.add_increases(yfg1,
                            yfg2,
                            evidence=test_evidence_text,
                            citation=test_citation_dict,
                            annotations={
                                'Disease': {
                                    'Disease1': True
                                },
                                'Cell': {
                                    'Cell1': True
                                }
                            })

        network = self.manager.insert_graph(graph, store_parts=True)

        self.manager.drop_network_by_id(network.id)
Пример #6
0
    def test_mixed_1(self):
        """Test mixed having location and something else."""
        self.graph.add_increases(
            Protein(namespace='HGNC', name='CDC42'),
            Protein(namespace='HGNC', name='PAK2'),
            evidence=
            """Summary: PAK proteins, a family of serine/threonine p21-activating kinases, include PAK1, PAK2,
         PAK3 and PAK4. PAK proteins are critical effectors that link Rho GTPases to cytoskeleton reorganization
         and nuclear signaling. They serve as targets for the small GTP binding proteins Cdc42 and Rac and have
         been implicated in a wide range of biological activities. PAK4 interacts specifically with the GTP-bound
         form of Cdc42Hs and weakly activates the JNK family of MAP kinases. PAK4 is a mediator of filopodia
         formation and may play a role in the reorganization of the actin cytoskeleton. Multiple alternatively
         spliced transcript variants encoding distinct isoforms have been found for this gene.""",
            citation={
                NAMESPACE: "Online Resource",
                IDENTIFIER: "PAK4 Hs ENTREZ Gene Summary"
            },
            annotations={'Species': '9606'},
            source_modifier=activity('gtp'),
            target_modifier=activity('kin'),
        )

        make_dummy_namespaces(self.manager, self.graph)
        make_dummy_annotations(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        edge = network.edges.first()
Пример #7
0
    def test_insert_with_list_annotations(self):
        """This test checks that graphs that contain list annotations, which aren't cached, can be loaded properly
        into the database."""
        graph = BELGraph(name='test', version='0.0.0')
        graph.annotation_list['TEST'] = {'a', 'b', 'c'}

        graph.add_increases(fos,
                            jun,
                            evidence=test_evidence_text,
                            citation=test_citation_dict,
                            annotations={'TEST': 'a'})

        make_dummy_namespaces(self.manager, graph)

        with mock_bel_resources:
            self.manager.insert_graph(graph)
Пример #8
0
    def test_object_degradation(self):
        self.graph.add_increases(
            Protein(name='YFG', namespace='HGNC'),
            Protein(name='YFG2', namespace='HGNC'),
            evidence=n(),
            citation=n(),
            object_modifier=degradation(),
        )
        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)

        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        edge = network.edges.first()
Пример #9
0
    def setUp(self):
        super(TestQuery, self).setUp()

        graph = BELGraph(name='test', version='0.0.0')
        graph.annotation_list['TEST'] = {'a', 'b', 'c'}

        graph.add_increases(fos,
                            jun,
                            evidence=test_evidence_text,
                            citation=test_citation_dict,
                            annotations={'TEST': 'a'})

        make_dummy_namespaces(self.manager, graph)
        make_dummy_annotations(self.manager, graph)

        with mock_bel_resources:
            self.manager.insert_graph(graph)
Пример #10
0
    def test_subject_location(self):
        self.graph.add_increases(Protein(name='YFG', namespace='HGNC'),
                                 Protein(name='YFG2', namespace='HGNC'),
                                 evidence=n(),
                                 citation=n(),
                                 subject_modifier=location(
                                     Entity(namespace='GO',
                                            name='nucleus',
                                            identifier='GO:0005634')))
        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)

        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        edge = network.edges.first()
Пример #11
0
    def test_translocation_default(self, mock):
        """This test checks that a translocation gets in the database properly"""
        self.graph.add_increases(
            Protein(name='F2', namespace='HGNC'),
            Protein(name='EDN1', namespace='HGNC'),
            evidence=
            'In endothelial cells, ET-1 secretion is detectable under basal conditions, whereas thrombin '
            'induces its secretion.',
            citation='10473669',
            subject_modifier=secretion())

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2,
                         network.nodes.count(),
                         msg='Missing one or both of the nodes.')
        self.assertEqual(1, network.edges.count(), msg='Missing the edge')
Пример #12
0
    def test_subject_translocation_custom_to_loc(self, mock):
        self.graph.add_increases(
            Protein(name='F2', namespace='HGNC'),
            Protein(name='EDN1', namespace='HGNC'),
            evidence=
            'In endothelial cells, ET-1 secretion is detectable under basal conditions, whereas thrombin induces its secretion.',
            citation='10473669',
            subject_modifier=translocation(
                from_loc=Entity(namespace='TEST', name='A'),
                to_loc=Entity(namespace='GO', name='extracellular space'),
            ))

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        edge = network.edges.first()
Пример #13
0
    def _help_reconstitute(self, node: BaseEntity, number_nodes: int,
                           number_edges: int):
        """Help test the round-trip conversion from PyBEL data dictionary to node model."""
        self.assertIsInstance(node, BaseEntity)

        graph = BELGraph(name='test', version='0.0.0')
        graph.add_node_from_data(node)

        make_dummy_namespaces(self.manager, graph)

        self.manager.insert_graph(graph)
        self.assertEqual(number_nodes, self.manager.count_nodes())
        self.assertEqual(number_edges, self.manager.count_edges())

        node_model = self.manager.get_or_create_node(graph, node)
        self.assertEqual(node.md5, node_model.md5)
        self.manager.session.commit()

        self.assertEqual(node, node_model.to_json())
        self.assertEqual(node, self.manager.get_dsl_by_hash(node.md5))
Пример #14
0
    def test_object_activity_default(self, mock):
        p1_name = n()
        p2_name = n()

        self.graph.add_increases(Protein(name=p1_name, namespace='HGNC'),
                                 Protein(name=p2_name, namespace='HGNC'),
                                 evidence=n(),
                                 citation=n(),
                                 target_modifier=activity('kin'))

        make_dummy_namespaces(self.manager, self.graph)

        network = self.manager.insert_graph(self.graph)
        self.assertEqual(2, network.nodes.count())
        self.assertEqual(1, network.edges.count())

        kin_list = self.manager.session.query(NamespaceEntry).filter(
            NamespaceEntry.name == 'kinase activity').all()
        self.assertEqual(1, len(kin_list))

        kin = list(kin_list)[0]
        self.assertEqual('kinase activity', kin.name)
Пример #15
0
 def test_upload_with_tloc(self, mock_get):
     """Test that the RAS translocation example graph can be uploaded."""
     make_dummy_namespaces(self.manager, ras_tloc_graph)
     to_database(ras_tloc_graph, manager=self.manager)