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

Add incremental converter builder #34

Merged
merged 8 commits into from
Feb 27, 2023
Merged

Add incremental converter builder #34

merged 8 commits into from
Feb 27, 2023

Conversation

cthoyt
Copy link
Member

@cthoyt cthoyt commented Feb 27, 2023

Closes #33, suggested by @kervel

  • Add interface for adding a new record
  • Add convenience interface for adding a new record by specifying parts (prefix, uri_prefix, syonyms)
  • Testing
  • Documentation

Demos

New prefixes can be added to an existing converter like in the following:

import curies

converter = curies.get_obo_converter()
converter.add_prefix("hgnc", "https://bioregistry.io/hgnc:")

Similarly, an empty converter can be instantiated using an empty list for the records argument and prefixes can be added one at a time (note this currently does not allow for adding synonyms separately):

import curies

converter = curies.Converter(records=[])
converter.add_prefix("hgnc", "https://bioregistry.io/hgnc:")

@cthoyt cthoyt marked this pull request as ready for review February 27, 2023 12:04
@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2023

Codecov Report

Merging #34 (6389a29) into main (3bb5fe2) will decrease coverage by 2.41%.
The diff coverage is 75.00%.

@@             Coverage Diff             @@
##              main      #34      +/-   ##
===========================================
- Coverage   100.00%   97.59%   -2.41%     
===========================================
  Files            5        5              
  Lines          267      291      +24     
  Branches        58       66       +8     
===========================================
+ Hits           267      284      +17     
- Misses           0        3       +3     
- Partials         0        4       +4     
Impacted Files Coverage Δ
src/curies/api.py 96.78% <75.00%> (-3.22%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cthoyt
Copy link
Member Author

cthoyt commented Feb 27, 2023

@kervel please take a look over this and let me know what you think

@kervel
Copy link

kervel commented Feb 27, 2023

hello,

i guess i would then use the

    def add_prefix(
        self,
        prefix: str,
        uri_prefix: str,
        prefix_synonyms: Optional[Collection[str]] = None,
        uri_prefix_synonyms: Optional[Collection[str]] = None,
    ) -> None:

this looks totally clear to me!
thanks a lot for this!

Greetings,
Frank

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.

Public API to build a converter incrementally
3 participants