我最近问了一个问题,关于将大约1000万个语句加载到启用了OWL推理的三重存储中的可行性。
这导致了一些StackOverflow的评论,以及我的研究小组内部关于我们是否真的需要OWL推理的讨论。
我将从一个似乎不需要OWL 推理的实际查询开始。
">41167-4120-0"是识别美国商业药品"盐酸非索非那定180 MG口服片[Allegra]"的NDC代码。
NDC的略微修改版本在药物本体中显示为标签(特别是文件dron-ndc.owl):
http://purl.obolibrary.org/obo/DRON_00604430 rdfs:label "41167412000"
DrON做出以下OWL断言:
http://purl.obolibrary.org/obo/DRON_00604430 is a packaged drug product
and is rdfs:subClass of
( has_proper_part some http://purl.obolibrary.org/obo/DRON_00083688 )
http://purl.obolibrary.org/obo/DRON_00083688
rdfs:subClassOf http://purl.obolibrary.org/obo/DRON_00062350
http://purl.obolibrary.org/obo/DRON_00062350 has_proper_part some
(scattered molecular aggregate
and (is bearer of some active ingredient)
and (is bearer of some (mass and
(has measurement unit label value milligram)
and (has specified value <value> )))
and (has granular part some fexofenadine))
ChEBI 说:
http://purl.obolibrary.org/obo/CHEBI_5050 rdfs:label "fexofenadine"
subClassOf (has role some anti-allergic agent)
和
http://purl.obolibrary.org/obo/CHEBI_50857 rdfs:label "anti-allergic agent"
因此,为了链接 NDC 代码和治疗角色,我可以编写如下所示的查询
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select distinct
?ndcval ?packdrugprod ?drugbrand ?brandlab ?drugform ?api ?apilab ?drugrole
where {
values ?ndcval {
"41167412000"
}
?packdrugprod rdfs:subClassOf ?hasproppart ;
rdfs:label ?ndcval .
?hasproppart a owl:Restriction ;
owl:onProperty <http://www.obofoundry.org/ro/ro.owl#has_proper_part> ;
owl:someValuesFrom ?drugbrand .
?drugbrand rdfs:subClassOf ?drugform ;
rdfs:label ?brandlab .
?drugform rdfs:subClassOf ?proppart .
?proppart a owl:Restriction ;
owl:onProperty <http://www.obofoundry.org/ro/ro.owl#has_proper_part> ;
owl:someValuesFrom ?valSource1 .
?valSource1 owl:intersectionOf ?intsect1 .
# scat mol agg
?intsect1 rdf:first obo:OBI_0000576 .
?intsect1 rdf:rest ?scatmolag .
?scatmolag rdf:first ?bearacting .
?scatmolag rdf:rest ?intsect3 .
# bearer of active ingredient
?bearacting a owl:Restriction ;
owl:onProperty obo:BFO_0000053 ;
owl:someValuesFrom obo:DRON_00000028 .
?intsect3 rdf:first ?granpart .
?intsect3 rdf:rest ?r .
# has granular part fexofenadine
?granpart a owl:Restriction ;
owl:onProperty obo:BFO_0000071 ;
owl:someValuesFrom ?api .
?api rdfs:subClassOf ?rolerestr ;
rdfs:label ?apilab .
# has anti allergic role
?rolerestr a owl:Restriction ;
owl:onProperty obo:RO_0000087 ;
owl:someValuesFrom ?drugrole .
?drugrole rdfs:label ?drlab .
values ?drugrole {
obo:CHEBI_50857
}
}
关注:
在没有推理的情况下访问嵌套的子类关系怎么样?
上面的例子很简单,因为非索非那定被直接断言具有"抗过敏"作用
如果我对服用硝酸酯的人感兴趣怎么办? 硝酸甘油是一种硝酸甘油,而硝酸甘油又是一种硝酸酯。 如果我使用未启用推理的存储库,我将不得不显式使用属性路径来查找正在服用任何硝酸酯的患者,并带有这样的片段(对吧?
?s rdfs:subClassOf* <http://purl.obolibrary.org/obo/CHEBI_51080> .
如何推断个人所属的类别?
如果我的本体说类似的话怎么办
:ViagraPill owl:equivalentClass ( :pill
and (:hasColor some :blue )
and (:hasShape some :diamond))
:steelBlue rdfs:subClassOf :blue
我有数据三元组,说类似
:patient1 :consumed :pill1 .
:pill1 :hasColor :steelBlue1 ;
:hasShape :diamond1 .
:steelBlue1 a :steelBlue .
:diamond1 a :diamond.
我想为服用伟哥药丸的患者写一个查询:
?patient a :patient ;
:consumed ?pill .
?pill a :ViagraPill .
我需要某种形式的OWL推理,对吧?
我一直认为OBO和其他生物,生命科学和农业本体论倾向于使用数百万个类,但很少有个人是一个错误。
上面的建模意味着,对于 Allegra 的每个实例(每一个药丸、一个盒子或其他包装),你需要推断出诸如"它是一个分散的分子聚集体"和"是某种活性成分的携带者"和"有一些颗粒部分非索非那定"之类的陈述。我觉得这很浪费。
最好将这些陈述直接附加到药物定义中:作为简单的陈述,而不是限制。您可以通过两种方式执行此操作:
- 仍然将 Allegra 视为一个类,但使用双关语将道具直接附加到它上面
- 以 Allegra 为例,如果您需要描述单个药丸,请使用类似
pill dct:type Allegra
然后,您可以简单地通过其药物(类或非类)访问药丸属性:
?pill rdf:type ?drug. # or in Variant2: dct:type
?drug obo:RO_0000087 obo:CHEBI_50857. # has anti allergic role
它将类似于您的查询,但非常简单,更快,因为它可以避免限制。
(至于解析rdf:Lists
的需要,那一定是本体论创造者意识的沉重负担):
?intsect1 rdf:first obo:OBI_0000576 .
?intsect1 rdf:rest ?scatmolag .
?scatmolag rdf:first ?bearacting .
?scatmolag rdf:rest ?intsect3 .
# bearer of active ingredient
这是简化形式的Viagram示例。我已经把命名法的值:blue
和:diamond
变成了个人(skos:Concept
),因为我认为它们没有理由成为类(:steelBlue1
对我来说毫无意义)。
:ViagraPill a DrugForm;
:hasColor :blue;
:hasShape :diamond.
:steelBlue a skos:Concept;
skos:broader :blue.
:patient1 :consumed :pill1.
:pill1 :hasColor :steelBlue; :hasShape :diamond.
颜色和形状是识别药物的必要条件,但不是充分条件,因此?drugForm
以下是该药丸的可能药物,但不确定:
select ?patient ?drugForm {
?patient a :patient; :consumed ?pill.
?pill :hasColor ?color; :hasShape ?shape.
?drugForm :hasColor ?color1; :hasShape ?shape.
?color skos:broaderTransitive? ?color1
}
在这里,我使用了传递推理:路径skos:broaderTransitive?
比路径skos:broader*
快。
推理不是全有或全无的事情:您可以从内置规则集中选择所需的规则。例如,如果您包含RDFS推理,则可以简化:
?x a ?s. ?s rdfs:subClassOf* :CHEBI_51080
到只是
?x a :CHEBI_51080
默认的内置规则集RDFS-Plus优化包括RDFS,逆和传递。 有关更多建议,请参阅 http://graphdb.ontotext.com/documentation/enterprise/rules-optimisations.html。
你可能会反对:"你不是说你会直接在毒品(类)上附加道具吗?你怎么也把它们附在上面的:pill1
?
我认为这很好:我们可以声明这些道具具有域:DrugIndividual or :DrugForm or :Drug
,并将它们解释为:DrugIndividual
"观察到",但对于:DrugForm and :Drug
"名义"或"必需"。 顺便说一句,我喜欢使用schema:domainIncludes ...
而不是rdfs:range [a owl:Class; owl:unionOf (...)]
来声明多态域。
如果您不想将道具附加到吸毒个体(实例)上,那么您将不得不为药丸使用"未知类",例如:
:patient1 :consumed :pill1.
:pill1 a [:hasColor :steelBlue; :hasShape :diamond].
查询略有复杂
:select ?patient ?drugForm {
?patient a :patient; :consumed ?pill.
?pill a [:hasColor ?color; :hasShape ?shape].
?drugForm :hasColor ?color1; :hasShape ?shape.
?color skos:broaderTransitive? ?color1
}
总结一下:
- GraphDB不支持OWL DL,它支持QL和RL。
- OBO风格的本体使用数百万个类,它规定了从类限制到个人的一大堆道具的推断;我觉得这是浪费。