Skip to content

Commit

Permalink
Fixed XrefRule and XrefUtil/Resolver issue - it couldn't detect db sp…
Browse files Browse the repository at this point in the history
…elling variants and so misreported "unknown.db"
  • Loading branch information
IgorRodchenkov committed Feb 16, 2024
1 parent b64b574 commit f1eb7fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
Expand Down Expand Up @@ -289,7 +290,7 @@ public boolean match(Collection<String> a, Collection<String> 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()));
Expand Down Expand Up @@ -321,9 +322,10 @@ public List<String> getSynonymsForDbName(String name) {

@Override
public String getPrimaryDbName(String name) {
List<String> names = getSynonymsForDbName(name);
List<String> 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 {
Expand All @@ -335,7 +337,8 @@ public String getPrimaryDbName(String name) {
public String getPrefix(String name) {
List<String> 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();
}
Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions biopax-validator/src/main/resources/codes.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit f1eb7fc

Please sign in to comment.