SPARQL: 如何将 owl:equivalentClass 转换为 rdfs:subClassOf (owl:Res



我的问题是关于使用SPARQL查询一些大量使用owl:Restrictions的猫头鹰本体(在我的例子中,这是"细胞本体"(。

以下是一些典型条目的示例(Turtle格式,摘自上述本体(:

###  http://purl.obolibrary.org/obo/CL_0000792
obo:CL_0000792 rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( obo:CL_0000624
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValuesFrom obo:PR_000001380
]
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002215 ;
owl:someValuesFrom obo:GO_0050777
]
[ rdf:type owl:Restriction ;
owl:onProperty <http://purl.obolibrary.org/obo/cl#has_low_plasma_membrane_amount> ;
owl:someValuesFrom obo:PR_000001869
]
) ;
rdf:type owl:Class
] ;
rdfs:subClassOf obo:CL_0000624 ,
obo:CL_0000815 ,
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValuesFrom obo:PR_000001380
] ,
[ rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002215 ;
owl:someValuesFrom obo:GO_0050777
] ,
[ rdf:type owl:Restriction ;
owl:onProperty <http://purl.obolibrary.org/obo/cl#has_low_plasma_membrane_amount> ;
owl:someValuesFrom obo:PR_000001869
] .

在这里,我的最终目标是将猫头鹰等效属性转移到subClassOf属性:

CL_0000792 rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:RO_0002104 ;
owl:someValueFrom obo:PR_000001380
] ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:onProperty obo:cl#has_low_plasma_membrane_amount ;
owl:someValueFrom obo:PR_000001869
] .

我没有实现的是从rdfs:subclass部分获取所有三个属性,然后将它们正确绑定到subClassOf种属性(然后过滤掉obo:RO_0002215很容易(。

编辑:当我在这里取得一些进展时,一个新的SPARQL查询

编辑2:遵循Damyan Ognyanov的回答更新了SPARQL查询部分,该部分忽略了owl:intersectionof部分中的集合,并且也更加紧凑/优雅

这是我当前的SPARQL查询:

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 tpo: <http://www.definiens.com/ontologies/TissuePhenomicsOntology>
PREFIX cl: <http://purl.obolibrary.org/obo/cl.owl>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX efo: <http://www.ebi.ac.uk/efo/efo.owl>
CONSTRUCT {
?cell rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue
] .
?cellProp ?cellPropProp ?cellPropObj .
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
}
FROM named cl:
FROM named tpo:
WHERE {
# query cl to get our information
graph cl:
{   
?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?x .
?x owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue .
?cellProp ?cellPropProp ?cellPropObj . 
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .
}
# limit ?cell to the entries already present in TPO
graph tpo:
{
?cell rdfs:subClassOf* obo:CL_0000000 .
}
}    

如果用SELECT *替换CONSTRUCT部分,则似乎所有变量都已正确分配,信息就在那里。

不过,我仍然缺少一个适当的CONSTRUCT部分来重建"有点复杂"的owl:Property限制。因此,此查询主要返回一长串空白节点,例如,Protege 不会正确解析这些节点。

@AKSW也正确地指出,SPARQL可能不是查询和构建OWL图的首选工具。这里确实清楚地表明,人们需要知道精确的数据结构才能构建一个工作查询,至少以这种方式。

?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first(( ?x . ?x owl:onProperty ?cellProp ; owl:someValuesFrom ?cellPropValue .

?cellProp ?cellPropProp?cellPropObj . ?cellPropValue ?cellPropValueProp ?cellPropValuePropValue . ?cell ?cellProp2 ?cellProp2Obj .

owl:intersectionOf

的值是一个RDF列表,上面的Turtle代码段使用RDF列表语法来枚举owl:intersectionOf集合的成员(例如,条目括在()之间(。

因此,还应在属性路径中包含rdf:rest*/rdf:first属性,因为这些属性用于构造集合。

对于查询,我将引入一个额外的变量,在其中绑定感兴趣的限制并使用它来获取owl:onPropertyowl:someValuesFrom的值,例如,您的WHERE子句可能如下所示:

?cell (rdfs:subClassOf|(owl:equivalentClass/owl:intersectionOf/rdf:rest*/rdf:first)) ?x .
?x owl:onProperty ?cellProp ;
owl:someValuesFrom ?cellPropValue .
?cellProp ?cellPropProp ?cellPropObj . 
?cellPropValue ?cellPropValueProp ?cellPropValuePropValue .
?cell ?cellProp2 ?cellProp2Obj .

最新更新