You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Widening base_uri to the namespace doubles the prefix in short forms and CURIEs (COHO_COHO_0000003) #1449
An ontology whose terms live at <namespace>/PREFIX_nnnnnnn and whose properties live at <namespace>/name cannot be configured so that both of these hold:
its terms get the right short form and CURIE (COHO_0000003, COHO:0000003), and
all of its own entities, properties included, count as defined by it (isDefiningOntology).
Widening base_uri from <namespace>/PREFIX_ to <namespace>/ fixes 2 and breaks 1: every term gets a doubled prefix. COHO is the example here, EFO has the same IRI layout (see #836).
COHO terms are http://www.ebi.ac.uk/coho/COHO_0000003, its properties are http://www.ebi.ac.uk/coho/isSubCohortOf. Results of loading COHO with each config, preferredPrefixCOHO throughout:
base_uri
term short form / CURIE
isSubCohortOf defining
imported terms' CURIEs
["http://www.ebi.ac.uk/coho/COHO_"]
COHO_0000003 / COHO:0000003
false
correct
["http://www.ebi.ac.uk/coho/"]
COHO_COHO_0000003 / COHO_COHO:0000003
true
correct
["http://www.ebi.ac.uk/coho/"] plus shortFormExtractionPattern^http://www\.ebi\.ac\.uk/coho/COHO_(\d+)$
COHO_0000003 / COHO:0000003
true
broken, see below
With the pattern set, the v1 API obo_id of imported terms became COHO:000002 (ExO_0000002), COHO:00118 (HP_0000118), COHO_:0700096 (MONDO_0700096), COHO:C16632 (NCIT_C16632).
With the wide base_uri and no pattern, the v1 individuals endpoint also returned obo_idCOHO:COHO:0000003, and properties get the short form COHO_isSubCohortOf.
Listing both base URIs (…/coho/COHO_ and …/coho/) does not help either, for the reason under "Cause" below.
Observed with the dataload image built from the #1443 branch at aa121f8. The two files involved, ShortFormAnnotator.java and OntologyBaseUris.java, are byte-identical on dev (30a9ec6), so dev behaves the same.
Expected behavior
With base_uri["http://www.ebi.ac.uk/coho/"], or with both base URIs listed:
http://www.ebi.ac.uk/coho/COHO_0000003 has short form COHO_0000003 and CURIE COHO:0000003
http://www.ebi.ac.uk/coho/isSubCohortOf counts as defined by COHO
imported terms keep their own CURIEs (MONDO:0700096, HP:0000118, …)
Cause
Two separate things in dataload/rdf2json/src/main/java/uk/ac/ebi/rdf2json/annotators/ShortFormAnnotator.java:
extractShortForm (lines 118-122) takes the first base URI the IRI starts with and returns preferredPrefix + "_" + rest:
for (StringbaseUri : ontologyBaseUris) {
if (uri.startsWith(baseUri) && preferredPrefix != null) {
returnpreferredPrefix + "_" + uri.substring(baseUri.length());
}
}
With the wide base URI the rest is COHO_0000003, so the prefix is doubled. The base URIs come from OntologyBaseUris.getOntologyBaseUris, which returns a HashSet, so when several base URIs match an IRI, the winner depends on hash order, not on specificity or on the order in the config. For COHO's two URIs, http://www.ebi.ac.uk/coho/ always iterates before http://www.ebi.ac.uk/coho/COHO_ (buckets 2 and 14 of 16), which is why listing both gives the doubled prefix as well.
When shortFormExtractionPattern is set (line 53), the CURIE of every entity whose short form contains _ is built as preferredPrefix + ":" + shortForm.substring(preferredPrefix.length() + 1), whether or not that entity's IRI matched the pattern. An imported ExO_0000002 becomes COHO: + "ExO_0000002".substring(5) = COHO:000002. So the pattern cannot be used as a workaround in an ontology that imports terms.
Suggested fix
In extractShortForm, match the longest base URI first (sort by length descending, or pick the longest match), so that a config listing both …/coho/COHO_ and …/coho/ behaves predictably.
Possibly also: if the rest after the base URI already starts with preferredPrefix + "_", don't prepend the prefix again. Then the wide base URI alone is enough.
Apply the pattern's CURIE rule only to entities whose IRI matched shortFormExtractionPattern.
ShortFormAnnotator has no unit tests at the moment. The three rows of the table above, plus an imported term, would make a small test.
Additional context
Term is showing as imported but it isn't #836 is the same layout in EFO: http://www.ebi.ac.uk/efo/reason_for_obsolescence shows as imported because base_uri is http://www.ebi.ac.uk/efo/EFO_. Widening it to http://www.ebi.ac.uk/efo/ was proposed there. With the current code that would turn EFO_0000001 into EFO_EFO_0000001.
Describe the bug
An ontology whose terms live at
<namespace>/PREFIX_nnnnnnnand whose properties live at<namespace>/namecannot be configured so that both of these hold:COHO_0000003,COHO:0000003), andisDefiningOntology).Widening
base_urifrom<namespace>/PREFIX_to<namespace>/fixes 2 and breaks 1: every term gets a doubled prefix. COHO is the example here, EFO has the same IRI layout (see #836).COHO terms are
http://www.ebi.ac.uk/coho/COHO_0000003, its properties arehttp://www.ebi.ac.uk/coho/isSubCohortOf. Results of loading COHO with each config,preferredPrefixCOHOthroughout:base_uriisSubCohortOfdefining["http://www.ebi.ac.uk/coho/COHO_"]COHO_0000003/COHO:0000003["http://www.ebi.ac.uk/coho/"]COHO_COHO_0000003/COHO_COHO:0000003["http://www.ebi.ac.uk/coho/"]plusshortFormExtractionPattern^http://www\.ebi\.ac\.uk/coho/COHO_(\d+)$COHO_0000003/COHO:0000003With the pattern set, the v1 API
obo_idof imported terms becameCOHO:000002(ExO_0000002),COHO:00118(HP_0000118),COHO_:0700096(MONDO_0700096),COHO:C16632(NCIT_C16632).With the wide
base_uriand no pattern, the v1 individuals endpoint also returnedobo_idCOHO:COHO:0000003, and properties get the short formCOHO_isSubCohortOf.Listing both base URIs (
…/coho/COHO_and…/coho/) does not help either, for the reason under "Cause" below.To Reproduce
dataload/configs/coho.jsonas of aa121f8 on the branch of COHO browsing: reified annotation display, aggregation hierarchy, subset tree filter #1443, reduced to the relevant keys).http://www.ebi.ac.uk/coho/COHO_0000003.COHO_COHO_0000003and its CURIECOHO_COHO:0000003.{ "ontologies": [ { "id": "coho", "preferredPrefix": "COHO", "base_uri": ["http://www.ebi.ac.uk/coho/"], "ontology_purl": "https://raw.githubusercontent.com/EBISPOT/cohort-ontology/refs/heads/main/coho.owl" } ] }Observed with the dataload image built from the #1443 branch at aa121f8. The two files involved,
ShortFormAnnotator.javaandOntologyBaseUris.java, are byte-identical ondev(30a9ec6), sodevbehaves the same.Expected behavior
With
base_uri["http://www.ebi.ac.uk/coho/"], or with both base URIs listed:http://www.ebi.ac.uk/coho/COHO_0000003has short formCOHO_0000003and CURIECOHO:0000003http://www.ebi.ac.uk/coho/isSubCohortOfcounts as defined by COHOMONDO:0700096,HP:0000118, …)Cause
Two separate things in
dataload/rdf2json/src/main/java/uk/ac/ebi/rdf2json/annotators/ShortFormAnnotator.java:extractShortForm(lines 118-122) takes the first base URI the IRI starts with and returnspreferredPrefix + "_" + rest:With the wide base URI the rest is
COHO_0000003, so the prefix is doubled. The base URIs come fromOntologyBaseUris.getOntologyBaseUris, which returns aHashSet, so when several base URIs match an IRI, the winner depends on hash order, not on specificity or on the order in the config. For COHO's two URIs,http://www.ebi.ac.uk/coho/always iterates beforehttp://www.ebi.ac.uk/coho/COHO_(buckets 2 and 14 of 16), which is why listing both gives the doubled prefix as well.When
shortFormExtractionPatternis set (line 53), the CURIE of every entity whose short form contains_is built aspreferredPrefix + ":" + shortForm.substring(preferredPrefix.length() + 1), whether or not that entity's IRI matched the pattern. An importedExO_0000002becomesCOHO:+"ExO_0000002".substring(5)=COHO:000002. So the pattern cannot be used as a workaround in an ontology that imports terms.Suggested fix
extractShortForm, match the longest base URI first (sort by length descending, or pick the longest match), so that a config listing both…/coho/COHO_and…/coho/behaves predictably.preferredPrefix + "_", don't prepend the prefix again. Then the wide base URI alone is enough.shortFormExtractionPattern.ShortFormAnnotatorhas no unit tests at the moment. The three rows of the table above, plus an imported term, would make a small test.Additional context
http://www.ebi.ac.uk/efo/reason_for_obsolescenceshows as imported becausebase_uriishttp://www.ebi.ac.uk/efo/EFO_. Widening it tohttp://www.ebi.ac.uk/efo/was proposed there. With the current code that would turnEFO_0000001intoEFO_EFO_0000001.base_urifor COHO in aa121f8, so as it stands it produces the doubled short forms wherever COHO is loaded with that config.