biopragmatics / curies

🐸 Idiomatic conversion between URIs and compact URIs (CURIEs) in Python
https://curies.readthedocs.io
MIT License
21 stars 6 forks source link

Add additional options to compress and expand #79

Closed cthoyt closed 11 months ago

cthoyt commented 11 months ago

Closes #63

This PR adds the strict and passthrough option, since many people typically implement these operations themselves. It also adds more specific examples to the "getting started" tutorial for these.

This means for @shawntanzk's use case, you can add passthrough=True when calling

import curies
import pandas as pd

uris = [
    "http://purl.obolibrary.org/obo/GO_0000010",
    "http://purl.obolibrary.org/obo/GO_0000011",
    "http://gudt.org/schema/gudt/baseCGSUnitDimensions",
    "http://qudt.org/schema/qudt/conversionMultiplier",
]
df = pd.DataFrame({"uri": uris})

converter = curies.get_obo_converter()
converter.pd_compress(df, column="uri", target_column="curie")

Gives

uri curie
http://purl.obolibrary.org/obo/UBPROP_0000010 GO:0000010
http://purl.obolibrary.org/obo/UBPROP_0000011 GO:0000011
http://gudt.org/schema/gudt/baseCGSUnitDimensions
http://qudt.org/schema/qudt/conversionMultiplier

But when adding passthrough=True in converter.pd_compress(df, column="uri", target_column="curie", passthrough=True), gives:

uri curie
http://purl.obolibrary.org/obo/GO_0000010 GO:0000010
http://purl.obolibrary.org/obo/GO_0000011 GO:0000011
http://gudt.org/schema/gudt/baseCGSUnitDimensions http://gudt.org/schema/gudt/baseCGSUnitDimensions
http://qudt.org/schema/qudt/conversionMultiplier http://qudt.org/schema/qudt/conversionMultiplier
codecov-commenter commented 11 months ago

Codecov Report

Merging #79 (892bc15) into main (135988c) will decrease coverage by 0.98%. Report is 9 commits behind head on main. The diff coverage is 95.54%.

@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
- Coverage   99.32%   98.35%   -0.98%     
==========================================
  Files           9       10       +1     
  Lines         593      729     +136     
  Branches      127      170      +43     
==========================================
+ Hits          589      717     +128     
- Misses          3       10       +7     
- Partials        1        2       +1     
Files Coverage Δ
src/curies/__init__.py 100.00% <100.00%> (ø)
src/curies/version.py 100.00% <100.00%> (ø)
src/curies/reconciliation.py 99.06% <99.06%> (ø)
src/curies/api.py 97.42% <87.50%> (-1.47%) :arrow_down:

... and 1 file with indirect coverage changes

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