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


Python ConjunctiveGraph.subject_objects方法代码示例

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


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

示例1: main

# 需要导入模块: from rdflib.graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.graph.ConjunctiveGraph import subject_objects [as 别名]
def main():
    parser = argparse.ArgumentParser(
        description='OMIA integration test',
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument(
        '--input', '-i', type=str, required=True,
        help='Location of input ttl file')

    args = parser.parse_args()

    graph = ConjunctiveGraph()
    graph.parse(args.input, format=rdflib_util.guess_format(args.input))

    model_of = URIRef('http://purl.obolibrary.org/obo/RO_0003301')

    models = graph.subject_objects(model_of)
    model_len = len(list(models))

    if model_len < EXPECTED_PAIRS:
        logger.error("Not enough model_of predicates in graph:"
                     " {} expected {} check omia log for"
                     " warnings".format(model_len, EXPECTED_PAIRS))
        exit(1)

    omim_diseases = graph.objects(
        subject=URIRef('https://monarchinitiative.org/model/OMIA-breed:18'),
        predicate=model_of
    )

    if list(omim_diseases) != [URIRef('http://purl.obolibrary.org/obo/OMIM_275220')]:
        logger.error("Missing breed to omim triple for {}".format('OMIA-breed:18'))
        exit(1)
    
    logger.info("PASSED")
开发者ID:DoctorBud,项目名称:dipper,代码行数:37,代码来源:omia-integration.py

示例2: main

# 需要导入模块: from rdflib.graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.graph.ConjunctiveGraph import subject_objects [as 别名]
def main():
    parser = argparse.ArgumentParser(
        description='OMIA integration test',
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument(
        '--input', '-i', type=str, required=True, help='Location of input ttl file')

    args = parser.parse_args()

    graph = ConjunctiveGraph()
    graph.parse(args.input, format=rdflib_util.guess_format(args.input))

    # "is model of": "RO:0003301"
    # is_model_of = URIRef('OBO:RO_0003301')
    is_model_of = URIRef('http://purl.obolibrary.org/obo/RO_0003301')

    # if we curie_map & globaltt here we could ...
    # (pfx lcl) = globaltt["is model of"].split(':')
    # iri = curie_map[pfx] + '_'.join((pfx, lcl))
    # is_model_of = URIRef(iri)

    models = graph.subject_objects(is_model_of)
    model_len = len(set(list(models)))

    if model_len < EXPECTED_PAIRS:
        LOG.error(
            "Not enough <RO:is model of> predicates in graph: found {}, "
            "expected {} check omia log for warnings".format(
                model_len, EXPECTED_PAIRS))
        exit(1)
    # else:
    #    LOG.info(
    #        "Found {} model_of predicates in graph, expected at least: {}".format(
    #            model_len, EXPECTED_PAIRS))

    breed = 'https://monarchinitiative.org/model/OMIA-breed:758'
    disease = 'http://omim.org/entry/305100'

    omim_diseases = graph.objects(
        subject=URIRef(breed),
        predicate=is_model_of
    )

    if list(omim_diseases) != [URIRef(disease)]:
        LOG.error("Missing breed to omim triple for %s", breed)
        LOG.error(list(omim_diseases))
        exit(1)

    LOG.info("PASSED")
开发者ID:TomConlin,项目名称:dipper,代码行数:52,代码来源:omia-integration.py

示例3: pprint

# 需要导入模块: from rdflib.graph import ConjunctiveGraph [as 别名]
# 或者: from rdflib.graph.ConjunctiveGraph import subject_objects [as 别名]

# just think .whatever((s, p, o))
# here we report on what we know

pprint(list(primer.subjects()))
pprint(list(primer.predicates()))
pprint(list(primer.objects()))

# and other things that make sense

# what do we know about pat?
pprint(list(primer.predicate_objects(myNS.pat)))

# who is what age?
pprint(list(primer.subject_objects(myNS.age)))



# Okay, so lets now work with a bigger
# dataset from the example, and start
# with a fresh new graph.


primer = ConjunctiveGraph()


# Lets start with a verbatim string straight from the primer text:

mySource = """
开发者ID:SpazioDati,项目名称:rdflib,代码行数:31,代码来源:swap_primer.py


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