Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable transitive reconciliaton #78

Merged
merged 10 commits into from
Sep 24, 2023
Merged

Enable transitive reconciliaton #78

merged 10 commits into from
Sep 24, 2023

Conversation

cthoyt
Copy link
Member

@cthoyt cthoyt commented Sep 24, 2023

Closes #75 as a follow-up to #74

This PR enables transitive reconciliation of CURIE prefix remapping. This solves the problem when you have a CURIE prefix remapping like {"geo": "ncbi.geo", "geogeo": "geo"}. It's smart enough to know that you want to first fix the name of geo then remap geogeo onto it.

This does not allow you to simply do {"geo": "ncbi.geo"} as this would create a clash, so nothing would happen when using this remapping.

Example usage:

from curies import Record, Converter, remap_curie_prefixes

records = [
    Record(prefix="geo", uri_prefix="https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc="),
    Record(prefix="geogeo", uri_prefix="http://purl.obolibrary.org/obo/GEO_"),
]
converter = Converter(records)
remapping = {"geo": "ncbi.geo", "geogeo": "geo"}

new_converter = remap_curie_prefixes(converter, remapping)
>>> new_converter.records
[
    Record(prefix='geo', uri_prefix='http://purl.obolibrary.org/obo/GEO_', prefix_synonyms=['geogeo'], uri_prefix_synonyms=[]), 
    Record(prefix='ncbi.geo', uri_prefix='https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=', prefix_synonyms=[], uri_prefix_synonyms=[])
]

@cthoyt cthoyt merged commit a3a1e39 into main Sep 24, 2023
@cthoyt cthoyt deleted the transitive-reconciliation branch September 24, 2023 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prefix reconciliation with transitive mappings
1 participant