openvax / gtfparse

Parsing tools for GTF (gene transfer format) files
Apache License 2.0
108 stars 25 forks source link

Incompatible with polars version >=0.17 due to usage of polars.toggle_string_cache #41

Closed stianlagstad closed 6 months ago

stianlagstad commented 9 months ago

Current master makes use of the polars.toggle_string_cache(True) function: https://github.com/openvax/gtfparse/blob/bb07cd1b675d307cf1107aa4435245d9496f60f0/gtfparse/read_gtf.py#L87.

This was renamed in polars v0.17, ref

When I use read_gtf with a newer version of polars (v0.19.6 in this case), then I get this exception:

venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:254: in read_gtf
    result_df = parse_gtf_and_expand_attributes(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:189: in parse_gtf_and_expand_attributes
    df = parse_gtf(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:155: in parse_gtf
    df_lazy = parse_with_polars_lazy(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:87: in parse_with_polars_lazy
    polars.toggle_string_cache(True)
E   AttributeError: module 'polars' has no attribute 'toggle_string_cache'

This is with the most recent version of gtfparse, i.e. v2.0.1.

I also found this stackoverflow question with the same issue: https://stackoverflow.com/questions/77160802/issue-using-infercnvpy-io-genomic-position-from-gtf.

If I pin polars to v0.16.18 then I get this other exception which I haven't dug into yet:

venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:254: in read_gtf
    result_df = parse_gtf_and_expand_attributes(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:189: in parse_gtf_and_expand_attributes
    df = parse_gtf(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:155: in parse_gtf
    df_lazy = parse_with_polars_lazy(
venv/lib/python3.8/site-packages/gtfparse/read_gtf.py:111: in parse_with_polars_lazy
    elif filepath_or_buffer.endswith(".gz") or filepath_or_buffer.endswith(".gzip"):
E   AttributeError: 'PosixPath' object has no attribute 'endswith'
PCJimmmy commented 9 months ago

I have read one gtf file successfully using gtfparse==1.3.0 and polars = 0.16.18

kmlhpk commented 8 months ago

Hi all, while you wait for the solution to be merged into the repo, you can manually use @y9c's patches (just edit the read_gtf.py file on your system) from PR #39 - I can vouch for them working.

alexpreynolds commented 6 months ago

Bump

iskandr commented 6 months ago

Fixed by https://github.com/openvax/gtfparse/pull/42 -- sorry I left this hanging for so long.