SPARQL:如何将owl:equivalentClass传递给rdfs:subClassOf(owl:Restriction)属性?

时间:2018-09-11 08:47:27

标签: sparql owl rdfs

我的问题是关于使用SPARQL查询某些猫头鹰本体,其中owl:Restrictions被大量使用(在我的情况下,这是“ Cell Ontology”)。

以下是一些典型条目的示例(采用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
                           ] .

这里我的最终目标是将owl等效属性转换为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查询

EDIT2:紧随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 .
    }
}    

如果将CONSTRUCT部分替换为SELECT *,则似乎所有变量均已正确分配,信息已存在。

尽管如此,我仍然缺少一个适当的CONSTRUCT部分来重构“有点复杂”的owl:Property限制。因此,此查询通常返回一长串空白节点,例如Protege无法正确解析。

@AKSW也正确地指出,SPARQL可能不是查询和构造OWL图的首选工具。实际上,在这里显然很明显,至少以这种方式,人们需要知道精确的数据结构才能构建有效的查询。

?cell(rdfs:subClassOf |(owl:equivalentClass / owl:intersectionOf / rdf:rest * / rdf:first))?x。 ?猫头鹰:onProperty?cellProp;    owl:someValuesFrom?cellPropValue。

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

1 个答案:

答案 0 :(得分:1)

owl:intersectionOf的值是一个RDF列表,上面的Turtle代码段使用RDF list语法枚举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 .