Skip to content

Commit

Permalink
Add synonyms in practice
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Nov 2, 2023
1 parent 8952a4f commit 6fdc65f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/bioregistry/record_accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def _add_prefix_prefixes(
primary_prefix = _add_primary_prefix(resource.prefix)
if primary_prefix is None:
continue
# TODO fix next line, since it seems to delete PUBMED from the OBO EPM
_add_synonym(synonym=resource.prefix, prefix=resource.prefix)
for synonym in resource.get_synonyms():
_add_synonym(synonym=synonym, prefix=resource.prefix)
for uri_prefix in resource.get_uri_prefixes():
Expand Down
15 changes: 9 additions & 6 deletions tests/test_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ def test_obo_context(self):
msg="When overriding, this means that bioregistry prefix isn't properly added to the synonyms list",
)

def get_obo_converter(self):
def test_get_obo_converter(self):
"""Test getting a converter from a context."""
converter = manager.get_converter_from_context("obo")
self.assertEqual("GO", converter.standardize_prefix("GO"))
self.assertEqual("GO", converter.standardize_prefix("gomf"))
# FIXME later, handle adding canonical bioregistry prefix
# as synonym when non-default prefix priority ordering is given
# self.assertEqual("GO", converter.standardize_prefix("go"))
self.assertEqual("GO", converter.standardize_prefix("GO", strict=True))
self.assertEqual("GO", converter.standardize_prefix("gomf", strict=True))
self.assertEqual("GO", converter.standardize_prefix("go", strict=True))
self.assertEqual("PMID", converter.standardize_prefix("pmid", strict=True))
self.assertEqual("PMID", converter.standardize_prefix("pubmed", strict=True))
self.assertEqual("PMID", converter.standardize_prefix("PubMed", strict=True))
# self.assertEqual("PMID", converter.standardize_prefix("PUBMED"))
# self.assertEqual("PMID", converter.standardize_prefix("PMID"))

def test_data(self):
"""Test the data integrity."""
Expand Down

0 comments on commit 6fdc65f

Please sign in to comment.