From f1eb7fcf1344d7278bf4be3adc08e2b6b1490c21 Mon Sep 17 00:00:00 2001 From: IgorRodchenkov Date: Fri, 16 Feb 2024 17:57:20 -0500 Subject: [PATCH] Fixed XrefRule and XrefUtil/Resolver issue - it couldn't detect db spelling variants and so misreported "unknown.db" --- .../biopax/validator/utils/OntologyUtils.java | 17 ++++++++++------- .../src/main/resources/codes.properties | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/biopax-validator/src/main/java/org/biopax/validator/utils/OntologyUtils.java b/biopax-validator/src/main/java/org/biopax/validator/utils/OntologyUtils.java index b417dbb3..c96c20db 100644 --- a/biopax-validator/src/main/java/org/biopax/validator/utils/OntologyUtils.java +++ b/biopax-validator/src/main/java/org/biopax/validator/utils/OntologyUtils.java @@ -215,7 +215,7 @@ public synchronized void init() { ontologyManager.loadOntologies(ontologyConfig); //Normalize ontology names for (String id : ontologyManager.getOntologyIDs()) { - Namespace ns = Resolver.getNamespace(id); + Namespace ns = Resolver.getNamespace(id, true); String officialName = id; if(ns != null) { officialName = ns.getName(); @@ -236,6 +236,7 @@ public synchronized void init() { // first, we prepare lists of db synonyms from // - Bioregistry.io (get each entry's prefix, name, synonyms) // - MI (OBO terms under the "database citation" root) + // but not adding the spelling variants from the Resolver.getSpellmap(). for (Namespace ns : Resolver.getNamespaces().values()) { String name = dbName(ns.getName()); //trim,uppercase String prefix = dbName(ns.getPrefix()); @@ -289,7 +290,7 @@ public boolean match(Collection a, Collection b) { } //if possible, move the prefix and preferred name on top (the order is important) String topName = merged.get(0); - Namespace ns = Resolver.getNamespace(topName); + Namespace ns = Resolver.getNamespace(topName, true); if(ns != null) { merged.add(0, dbName(ns.getPrefix())); merged.add(1, dbName(ns.getName())); @@ -321,9 +322,10 @@ public List getSynonymsForDbName(String name) { @Override public String getPrimaryDbName(String name) { - List names = getSynonymsForDbName(name); + List names = getSynonymsForDbName(name); //these synonyms do not usually include all spelling variants if (names.isEmpty()) { - return null; + Namespace ns = Resolver.getNamespace(name, true); //also search in spelling variants + return ns != null ? ns.getName() : null; } else if (names.size() > 1) { return names.get(1); } else { @@ -335,7 +337,8 @@ public String getPrimaryDbName(String name) { public String getPrefix(String name) { List names = getSynonymsForDbName(name); if (names.isEmpty()) { - return null; + Namespace ns = Resolver.getNamespace(name, true); //also search in spelling variants + return ns != null ? ns.getPrefix() : null; } else { return names.get(0).toLowerCase(); } @@ -350,13 +353,13 @@ public boolean checkIdFormat(String db, String id) { @Override public boolean canCheckIdFormatIn(String name) { String db = getPrimaryDbName(name); - Namespace ns = Resolver.getNamespace(db); + Namespace ns = Resolver.getNamespace(db, true); return ns != null && StringUtils.isNotBlank(ns.getPattern()); } @Override public String getRegexpString(String db) { - Namespace ns = Resolver.getNamespace(getPrimaryDbName(db)); + Namespace ns = Resolver.getNamespace(getPrimaryDbName(db), true); //TODO: why primary name?.. return (ns != null) ? ns.getPattern() : null; } diff --git a/biopax-validator/src/main/resources/codes.properties b/biopax-validator/src/main/resources/codes.properties index 4e35da4d..3ce0f8bc 100644 --- a/biopax-validator/src/main/resources/codes.properties +++ b/biopax-validator/src/main/resources/codes.properties @@ -69,7 +69,7 @@ invalid.id.format.default=Xref 'id' value does not match the standard pattern fo invalid.id.format=db: {0} (recognized as: {1}), id: {2}, pattern: {3} invalid.id.format.category=recommendation -unknown.db.default=Unknown database identifier. For Xref 'db' property and Provenance standard/display name properties, please use the official database names from MIRIAM. PSI-MI "database citation" and child terms are also allowed but they are deprecated. Please use MIRIAM when possible +unknown.db.default=Unknown database identifier. For Xref 'db' property and Provenance standard/display name properties, please use the official database name/prefix or synonym. MI "database citation" and child terms are also allowed but deprecated. Please use Bioregistry. unknown.db=db name: {0} unknown.db.category=recommendation @@ -81,7 +81,7 @@ cloned.utility.class.default=Two or more BioPAX objects are equivalent. Equivale cloned.utility.class=equivalent elements: {0} (utility class: {1}) cloned.utility.class.category=recommendation -shared.unification.xref.default=Two or more elements share the same unification xref. Please note that defining a UnificationXref to an external resource implies that this object and external resource are identical. Therefore elements that share the same unification xref must also be identical. Please consider merging these elements if they are identical, otherwise please consider converting this external reference to a RelationshipXref +shared.unification.xref.default=Two or more elements share the same unification xref. Please note that defining a UnificationXref to an external resource implies that this object and external resource are identical. Therefore, elements that share the same unification xref must also be identical. Please consider merging these elements if they are identical, otherwise please consider converting this external reference to a RelationshipXref shared.unification.xref=is the xref of: {0} shared.unification.xref.category=recommendation