openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
868 stars 210 forks source link

Redirects in federated SPARQL queries #447

Open andyjenkinson opened 9 years ago

andyjenkinson commented 9 years ago

Hi,

I notice that Virtuoso (7.2.0.1) does not follow HTTP redirects (301) when federating SPARQL queries using the SERVICE keyword. The UniProt endpoint has just come out of beta and consequently changed URL, from http://beta.sparql.uniprot.org to http://sparql.uniprot.org. A redirect is in place but Virtuoso does not follow it, instead giving an error:

Virtuoso RDFZZ Error DB.DBA.SPARQL_REXEC('http://beta.sparql.uniprot.org/sparql', ...) returned Content-Type 'text/html' status 'HTTP/1.0 301 Moved Permanently

301 Moved Permanently

Moved Permanently
The document has moved here.

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
PREFIX rdf: 
PREFIX rdfs: 
PREFIX owl: 
PREFIX dcterms: 
PREFIX obo: 
PREFIX sio: 
PREFIX efo: 
PREFIX atlas: 
PREFIX atlasterms: 

PREFIX upc:
PREFIX identifiers:

SELECT distinct ?valueLabel ?goid ?golabel 
WHERE { 
?value rdfs:label ?valueLabel .
?value atlasterms:isMeasurementOf ?probe  .
?probe atlasterms:dbXref identifiers:ENSG00000129991  .
?probe atlasterms:dbXref ?uniprot .
SERVICE  {   
?uniprot a upc:Protein  .
?uniprot upc:classifiedWith ?keyword  .
?keyword rdfs:seeAlso ?goid  .
?goid rdfs:label ?golabel  .
}   
}

Is this expected behaviour. Would it be different for a temporary redirect (302)?

Cheers, Andy

HughWilliams commented 9 years ago

@andyjenkinson:

For some reason even though you have wrapped the output in comments git is stripping out anything enclosed between <....> so the prefixes and endpoint name (I presume http://beta.sparql.uniprot.org ) etc are missing.

So can you email me the query so we have the complete thing to attempt recreation locally ?

andyjenkinson commented 9 years ago

Actually it is not github, but Virtuoso conductor that is stripping them out. However I just realised that endpoint I am talking about is actually an old v6 one (6.1.7.2). A similar query on a 7.2.0.1 endpoint works as expected.

Presumably this is a know difference between versions, and we would have to upgrade to resolve it?

Just for completeness, here's the query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX efo: <http://www.ebi.ac.uk/efo/>
PREFIX atlas: <http://rdf.ebi.ac.uk/resource/atlas/>
PREFIX atlasterms: <http://rdf.ebi.ac.uk/terms/atlas/>

PREFIX upc:<http://purl.uniprot.org/core/>
PREFIX identifiers:<http://identifiers.org/ensembl/>

SELECT distinct ?valueLabel ?goid ?golabel 
WHERE { 
?value rdfs:label ?valueLabel .
?value atlasterms:isMeasurementOf ?probe  .
?probe atlasterms:dbXref identifiers:ENSG00000129991  .
?probe atlasterms:dbXref ?uniprot .
SERVICE <http://beta.sparql.uniprot.org/sparql> {   
?uniprot a upc:Protein  .
?uniprot upc:classifiedWith ?keyword  .
?keyword rdfs:seeAlso ?goid  .
?goid rdfs:label ?golabel  .
}   
}

This query is better to use as a test, as it should work on any endpoint:

PREFIX up:<http://purl.uniprot.org/core/> 
PREFIX taxon:<http://purl.uniprot.org/taxonomy/> 
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 

SELECT ?protein ?aa  WHERE {
  SERVICE <http://beta.sparql.uniprot.org/sparql> {   
    SELECT ?protein ?aa 
    WHERE
    {
      ?protein a up:Protein .
      ?protein up:organism ?organism . 
      ?protein up:organism taxon:83333 .
      ?protein up:sequence ?s .
      ?s rdf:value ?aa
    }
  }
}
HughWilliams commented 9 years ago

@andyjenkinson:

OK, development have confirmed that redirects are supported in Virtuoso 7 but in Virtuoso 6, which would account for the failed to redirect when testing against the v6 instance.

Have all the EBI Virtuoso SPARQL endpoints not been upgraded to Virtuoso 7 ?

andyjenkinson commented 9 years ago

No, not all of them.