当前位置: 首页>>代码示例>>Python>>正文


Python Graph._getNode方法代码示例

本文整理汇总了Python中rdflib.Graph._getNode方法的典型用法代码示例。如果您正苦于以下问题:Python Graph._getNode方法的具体用法?Python Graph._getNode怎么用?Python Graph._getNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rdflib.Graph的用法示例。


在下文中一共展示了Graph._getNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: InteractionsTestCase

# 需要导入模块: from rdflib import Graph [as 别名]
# 或者: from rdflib.Graph import _getNode [as 别名]
class InteractionsTestCase(unittest.TestCase):

    def setUp(self):
        self.graph = Graph()

        self.curie_map = curie_map.get()
        self.ctd = CTD('rdf_graph', True)
        self.ctd.g = self.ctd.graph
        row1 = [
            '06-Paris-LA-66 protocol', 'C046983', 'foo',
            'Precursor Cell Lymphoblastic Leukemia-Lymphoma', 'MESH:D054198',
            'therapeutic', 'bar', 'baz', 'foo', '4519131']
        row2 = [
            '10,10-bis(4-pyridinylmethyl)-9(10H)-anthracenone', 'C112297',
            'foo', 'Hyperkinesis', 'MESH:D006948', 'marker/mechanism',
            'bar', 'baz', 'foo', '19098162']

        self.ctd._process_interactions(row1)
        self.ctd._process_interactions(row2)

    def tearDown(self):
        self.ctd.graph = None
        self.ctd = None

    def test_therapeutic_relationship(self):
        from dipper.utils.TestUtils import TestUtils
        from dipper.utils.GraphUtils import GraphUtils

        # Make testutils object and load bindings
        test_query = TestUtils(self.ctd.graph)

        # Expected structure
        sparql_query = """
                       SELECT ?assoc ?pubmed ?disease ?chemical
                       WHERE {
                       ?assoc a Annotation: ;
                           dc:evidence OBO:ECO_0000033 ;
                           dc:source ?pubmed ;
                           :hasObject ?disease ;
                           :hasPredicate OBO:RO_0002606 ;
                           :hasSubject ?chemical .}
                       """

        # SPARQL variables to check
        chem_id = 'MESH:D009538'
        chem_uri = self.graph._getNode(chem_id)
        disease_id = 'OMIM:188890'
        disease_uri = self.graph._getNode(disease_id)
        pubmed_id = 'PMID:16785264'
        pubmed_uri = self.graph._getNode(pubmed_id)
        rel_id = self.model.object_properties['substance_that_treats']
        eco = 'ECO:0000033'
        # TODO PYLINT  make_association_id() does not exist in CTD
        # there is "_make_association()" with a different sig

        assoc_id = self.ctd.make_association_id(
            'ctd', chem_id, rel_id, disease_id, eco, pubmed_id)
        assoc_uri = self.graph._getNode(assoc_id)

        # Expected output from query
        expected_output = [assoc_uri, pubmed_uri, disease_uri, chem_uri]

        # Query graph
        sparql_output = test_query.query_graph(sparql_query)

        self.assertTrue(expected_output in sparql_output)

        logger.info("Test finished.")
开发者ID:DoctorBud,项目名称:dipper,代码行数:70,代码来源:test_interactions.py


注:本文中的rdflib.Graph._getNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。