1

I'm trying to execute a very simple SPARQL query to retrieve information about a specific disease using https://bioportal.bioontology.org/ontologies/SNOMEDCT/?p=classes&conceptid=root (in Java) based on a name passed in the query string, and I don't understand why it's not working. Here are the relevant code:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT *
FROM <http://bioportal.bioontology.org/ontologies/SNOMEDCT>
FROM <http://bioportal.bioontology.org/ontologies/globals>
WHERE
{
    ?x rdfs:label ?label .
    FILTER (CONTAINS ( UCASE(str(?label)), "MELANOMA") )
}
Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
ela
  • 13
  • 3

1 Answers1

2

The only occurrence of rdfs:label in SNOMED-CT on BioPortal is snomed-term: rdfs:label "SNOMEDCT". BioPortal uses skos:prefLabel (which is a subproperty of rdfs:label) instead.

Try this query:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX snomed-term: <http://purl.bioontology.org/ontology/SNOMEDCT/>

SELECT DISTINCT *
FROM <http://bioportal.bioontology.org/ontologies/SNOMEDCT>
FROM <http://bioportal.bioontology.org/ontologies/globals>
WHERE {
    ?x skos:prefLabel ?label .
    FILTER (CONTAINS ( UCASE(str(?label)), "MELANOMA") )
}

There should be 10 results.

If you need to restrict results to diseases, probably you'd have to add ?x rdfs:subClassOf+ snomed-term:64572001 to your query. But unfortunately, it seems that the BioPortal SPARQL endpoint doesn't support SPARQL 1.1 property paths.

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
  • 1
    Do you have any idea why it does not return all the results? For example, if I change `FILTER (CONTAINS ( UCASE(str(?label)), "MELANOMA") )` to `FILTER ( STR(?prefLabel)="Edema")` I'm not getting any results, even though, on a manual search on ontology there are 3 results. – ela Apr 17 '18 at 18:19
  • @ela, I suppose, you mean `:267038008`, `:79654002` and `:423666004`. Well, BioPortal [say](https://www.bioontology.org/wiki/index.php/SPARQL_BioPortal#Partial_or_Incomplete_Results): "***Partial or Incomplete Results**. Sparql.bioontology.org uses 4store's soft-limit internal mechanism to limit resources for expensive queries.*" etc. `FILTER (?label = "Edema"@en)` works better. Or use your own local endpoint. – Stanislav Kralin Apr 17 '18 at 19:53
  • Thank you so much. I really appreciate all the help you have given me with my bugs. – ela Apr 17 '18 at 21:20