agroportal / project-management

Repository used to consolidate documentation about the AgroPortal project and track content related issues.
http://agroportal.lirmm.fr
7 stars 0 forks source link

Extract ontology mappings (excatMatch,...) #302

Closed syphax-bouazzouni closed 1 year ago

syphax-bouazzouni commented 1 year ago

Requirement

If inside the class/concepts defintion are defined mapping relations (need to be defined and listed), we should extract them and add them to the mapping list of the class/concept.

Actually they are only showed the class/concept details

Image

The proposed solution

is to upgrade the SPARQL query used to fetch the mapping, defined in def self.mappings_ontologies(sub1, sub2, page, size, classId = nil, reload_cache = false)

The request will go from


SELECT DISTINCT ?s1 ?s2 ?g ?source ?o
WHERE {
 {  
     GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> {     
      ?s1 <http://bioportal.bioontology.org/ontologies/umls/cui> ?o .
     } 
     GRAPH ?g {      
       ?s2 <http://bioportal.bioontology.org/ontologies/umls/cui> ?o .  
     }  
     BIND ('CUI' AS ?source) 
 } 
 UNION 
 { 
     GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> {
      ?s1 <http://data.bioontology.org/metadata/def/mappingSameURI> ?o .
     } 
     GRAPH ?g {
      ?s2 <http://data.bioontology.org/metadata/def/mappingSameURI> ?o .
     } 
     BIND ('SAME_URI' AS ?source 
} 
UNION
{  
    GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> { 
     ?s1 <http://data.bioontology.org/metadata/def/mappingLoom> ?o .
    } 
    GRAPH ?g {
     ?s2 <http://data.bioontology.org/metadata/def/mappingLoom> ?o .
    }
    BIND ('LOOM' AS ?source)
 } 
 UNION 
 { 
    GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> { 
     ?s1 <http://data.bioontology.org/metadata/def/mappingRest> ?o . 
      } 
    GRAPH ?g {
     ?s2 <http://data.bioontology.org/metadata/def/mappingRest> ?o .  
    }  
    BIND ('REST' AS ?source)}
 }
 FILTER ((?s1 != ?s2) || (?source = 'SAME_URI'))
 FILTER (!STRSTARTS(str(?g),'http://data.bioontology.org/ontologies/E-PHY'))
} 
OFFSET 0 LIMIT 50

To


SELECT DISTINCT ?s1 ?s2 ?g ?source ?o
WHERE {
 {  
     GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> {     
      ?s1 <http://bioportal.bioontology.org/ontologies/umls/cui> ?o .
     } 
     GRAPH ?g {      
       ?s2 <http://bioportal.bioontology.org/ontologies/umls/cui> ?o .  
     }  
     BIND ('CUI' AS ?source) 
 } 
 UNION 
 { 
     GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> {
      ?s1 <http://data.bioontology.org/metadata/def/mappingSameURI> ?o .
     } 
     GRAPH ?g {
      ?s2 <http://data.bioontology.org/metadata/def/mappingSameURI> ?o .
     } 
     BIND ('SAME_URI' AS ?source 
} 
UNION
{  
    GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> { 
     ?s1 <http://data.bioontology.org/metadata/def/mappingLoom> ?o .
    } 
    GRAPH ?g {
     ?s2 <http://data.bioontology.org/metadata/def/mappingLoom> ?o .
    }
    BIND ('LOOM' AS ?source)
 } 
 UNION 
 { 
    GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> { 
     ?s1 <http://data.bioontology.org/metadata/def/mappingRest> ?o . 
      } 
    GRAPH ?g {
     ?s2 <http://data.bioontology.org/metadata/def/mappingRest> ?o .  
    }  
    BIND ('REST' AS ?source)}
 }
 UNION 
 { 
    GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> { 
     ?s1 <http://data.bioontology.org/metadata/def/mappingRest> ?o . 
      } 
    GRAPH ?g {
     ?s2 <http://data.bioontology.org/metadata/def/mappingRest> ?o .  
    }  
    BIND ('REST' AS ?source)}
 }
UNION
{  
   GRAPH <http://data.bioontology.org/ontologies/E-PHY/submissions/1> {     
      ?s1 <http://www.w3.org/2004/02/skos/core#exactMatch> ?s2 .
     } 
     BIND( <http://data.bioontology.org/ontologies/E-PHY/submissions/1> as ?g)
     BIND( ?s2 AS ?o)
     BIND ('SKOS:EXACT_MATCH' AS ?source) 
 } 
 FILTER ((?s1 != ?s2) || (?source = 'SAME_URI'))
 FILTER (!STRSTARTS(str(?g),'http://data.bioontology.org/ontologies/E-PHY') || ((?source = 'SKOS:EXACT_MATCH')))
} 
OFFSET 0 LIMIT 50

TODO

syphax-bouazzouni commented 1 year ago

The list of mapping relation to extract (for now)

jonquet commented 1 year ago

Note for later : we will need to add alos: owl:sameAs and oboInOwl:hasDbXref has not.