导入的 .owl 文件在前缀中有 #'s 与原始 rdf4j triplestore

imported .owl files have #'s in prefixes vs original rdf4j triplestore

当我导入转储“PathwayCommons12.All.BIOPAX.owl.gz”时(linked from this page) of this Virtuoso triplestore,我注意到在各种 URI 的前缀后插入了“#”。

特别是以下查询 runs on the original endpoint:

# Query 1
PREFIX pfx: <http://pathwaycommons.org/pc12/>

select ?pw 
where {
?pw a bp:Pathway
values ?pw {pfx:Pathway_c2fd3d95c8c65552a0514393ede60c37}
}

但是要在本地端点 运行 上获取它(导入的 owl 转储),我必须在 pfx: 的末尾添加一个“#”,例如:

# Query 2
PREFIX pfx: <http://pathwaycommons.org/pc12/#>

select ?pw 
where {
?pw a bp:Pathway
values ?pw {pfx:Pathway_c2fd3d95c8c65552a0514393ede60c37}
}

请注意,查询 1 仅适用于原始端点,而查询 2 仅适用于本地端点。

这是怎么回事?

如果我们查看那个庞大 RDF/XML 文件的前几行,我们会看到:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:bp="http://www.biopax.org/release/biopax-level3.owl#"
 xml:base="http://pathwaycommons.org/pc12/">
<owl:Ontology rdf:about="">
 <owl:imports rdf:resource="http://www.biopax.org/release/biopax-level3.owl#" />
</owl:Ontology>

<bp:ExperimentalForm rdf:ID="ExperimentalForm_ee10aeab-1129-49ad-8217-4193f4fbf7e0">
 <bp:comment rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">[ExperimentalFormVocabulary_bait]</bp:comment>
 <bp:experimentalFormDescription rdf:resource="#ExperimentalFormVocabulary_701737e5cf53d06134cbd3ee59611827" />
</bp:ExperimentalForm>

注意此处 rdf:ID 属性的值:“ExperimentalForm_ee10aeab-1129-49ad-8217-4193f4fbf7e0”。这是一个相对 URI,需要根据基本 URI(在文档 header: "http://pathwaycommons.org/pc12/" 中声明)进行解析。 section 2.14 of the RDF/XML syntax specifcation:

中描述了该解决方案应该如何发生

The rdf:ID attribute on a node element (not property element, that has another meaning) can be used instead of rdf:about and gives a relative IRI equivalent to # concatenated with the rdf:ID attribute value. So for example if rdf:ID="name", that would be equivalent to rdf:about="#name".

(强调我的)

规范中的

Example 16 进一步说明了这一点。

归根结底,在解析此 RDF/XML 时,作为 rdf:ID 属性提供的值全部解析为 http://pathwaycommons.org/pc12/#<ID>。因此,对于给定的输入,您在 GraphDB 中获得的结果是正确的。我不知道为什么它在 Virtuoso 端点中有所不同:他们使用了不同的输入文件,或者他们的解析器中有错误,或者用于生成此转储文件的任何工具都包含错误。

可以肯定地说,创建转储文件的人的意图rdf:ID="ExperimentalForm_ee10aeab-1129-49ad-8217-4193f4fbf7e0" 将解析为 IRI http://pathwaycommons.org/pc12/ExperimentalForm_ee10aeab-1129-49ad-8217-4193f4fbf7e0(即没有添加 # 字符)。有几种方法可以在文件中修复此问题:用 rdf:about 替换所有出现的 rdf:ID,或者不依赖于相对 URI 解析,只使用完整的 URI 作为 rdf:ID值。