This is the original question(这是第二部分)。
我正在使用HyperGraphQL基于EBI-RDF sparql endpoint查询this tutorial。
当我执行此GraphQL查询以检索GO_0044727
的父母时:
{
Class_GET_BY_ID(uris:[
"http://purl.obolibrary.org/obo/GO_0044727"]) {
id
label
subClassOf {
id
label
subClassOf {
id
label
subClassOf { # <--- 4th sub level
id
label
}
}
}
}
}
我没有结果:
{
"extensions": {},
"data": {
"@context": {
"_type": "@type",
"_id": "@id",
"label": "http://www.w3.org/2000/01/rdf-schema#label",
"id": "http://www.geneontology.org/formats/oboInOwl#id",
"Class_GET_BY_ID": "http://hypergraphql.org/query/Class_GET_BY_ID",
"subClassOf": "http://www.w3.org/2000/01/rdf-schema#subClassOf"
},
"Class_GET_BY_ID": []
},
"errors": []
}
在日志中,我得到了错误:
java.util.concurrent.ExecutionException: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.hypergraphql.datafetching.services.SPARQLEndpointService.iterateFutureResults(SPARQLEndpointService.java:86)
at org.hypergraphql.datafetching.services.SPARQLEndpointService.executeQuery(SPARQLEndpointService.java:69)
at org.hypergraphql.datafetching.ExecutionTreeNode.generateTreeModel(ExecutionTreeNode.java:357)
at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:21)
at org.hypergraphql.datafetching.FetchingExecution.call(FetchingExecution.java:8)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.jena.query.QueryException: Endpoint returned Content-Type: text/html which is not rcognized for SELECT queries
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(QueryEngineHTTP.java:377)
at org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngineHTTP.java:344)
at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:81)
at org.hypergraphql.datafetching.SPARQLEndpointExecution.call(SPARQLEndpointExecution.java:33)
... 4 more
根据上面的GraphQL查询生成的SPARQL查询:
SELECT *
WHERE {
GRAPH <http://rdf.ebi.ac.uk/dataset/go> {
VALUES ?x_1 { <http://purl.obolibrary.org/obo/GO_0044727> }
?x_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
OPTIONAL {
?x_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1 .?x_1_1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_1 . }
OPTIONAL { ?x_1_1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2 .?x_1_1_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
OPTIONAL { ?x_1_1_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_1 . }
OPTIONAL {
?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?x_1_1_2_2 .?x_1_1_2_2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#Class> .
OPTIONAL { ?x_1_1_2_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_2_1 . }
OPTIONAL { ?x_1_1_2_2 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_2_2_2 . }
}
OPTIONAL { ?x_1_1_2 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_1_2_3 . }
}
OPTIONAL { ?x_1_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_1_3 . }
}
OPTIONAL { ?x_1 <http://www.w3.org/2000/01/rdf-schema#label> ?x_1_2 . }
OPTIONAL { ?x_1 <http://www.geneontology.org/formats/oboInOwl#id> ?x_1_3 . }
}
}
我通过在?force
文件(行:config.json
)中添加"url": "http://www.ebi.ac.uk/rdf/services/sparql?force"
来尝试@AKSW回答here,但是没有用。
我认为查询时间可能太长,但是当我tested the query时,它没有给出任何错误。
答案 0 :(得分:0)
我发现的唯一解决方案是使用local RDF file查询基因本体:
java -jar ont-converter.jar -i go.owl -o go_ont.ttl -of ttl -v
配置的HyperGraphQL:
goconfig.json
文件:
{
"name": "go-hgql",
"schema": "schemas/goschema.graphql",
"server": {
"port": 8082,
"graphql": "/graphql",
"graphiql": "/graphiql"
},
"services": [
{
"id": "go-local",
"type": "LocalModelSPARQLService",
"filepath": "go_ont.ttl", # <----- the TTL file
"filetype": "TTL"
}
]
}
goschema.graphql
:
type __Context {
Class: _@href(iri: "http://www.w3.org/2002/07/owl#Class")
id: _@href(iri: "http://www.geneontology.org/formats/oboInOwl#id")
label: _@href(iri: "http://www.w3.org/2000/01/rdf-schema#label")
subClassOf: _@href(iri: "http://www.w3.org/2000/01/rdf-schema#subClassOf")
}
type Class @service(id:"go-local") {
id: [String] @service(id:"go-local")
label: [String] @service(id:"go-local")
subClassOf: [Class] @service(id:"go-local")
}
使用配置文件启动HyperGraphQL:
java -jar build/libs/hypergraphql-1.0.3-exe.jar --config hgql/config/goconfig.json