gtfparse 2.8.0__tar.gz → 2.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {gtfparse-2.8.0 → gtfparse-2.8.1}/PKG-INFO +1 -1
  2. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/__init__.py +1 -1
  3. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/read_gtf.py +4 -3
  4. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse.egg-info/PKG-INFO +1 -1
  5. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse.egg-info/SOURCES.txt +1 -0
  6. gtfparse-2.8.1/tests/test_polars_compatibility.py +51 -0
  7. {gtfparse-2.8.0 → gtfparse-2.8.1}/LICENSE +0 -0
  8. {gtfparse-2.8.0 → gtfparse-2.8.1}/README.md +0 -0
  9. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/attribute_parsing.py +0 -0
  10. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/create_missing_features.py +0 -0
  11. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/parsing_error.py +0 -0
  12. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse/write_gtf.py +0 -0
  13. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse.egg-info/dependency_links.txt +0 -0
  14. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse.egg-info/requires.txt +0 -0
  15. {gtfparse-2.8.0 → gtfparse-2.8.1}/gtfparse.egg-info/top_level.txt +0 -0
  16. {gtfparse-2.8.0 → gtfparse-2.8.1}/pyproject.toml +0 -0
  17. {gtfparse-2.8.0 → gtfparse-2.8.1}/requirements.txt +0 -0
  18. {gtfparse-2.8.0 → gtfparse-2.8.1}/setup.cfg +0 -0
  19. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_create_missing_features.py +0 -0
  20. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_ensembl_gtf.py +0 -0
  21. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_expand_attribute_column_false.py +0 -0
  22. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_expand_attributes.py +0 -0
  23. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_gencode_gtf.py +0 -0
  24. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_multiple_values_for_tag_attribute.py +0 -0
  25. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_parse_gtf_lines.py +0 -0
  26. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_read_stringtie_gtf.py +0 -0
  27. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_refseq_gtf.py +0 -0
  28. {gtfparse-2.8.0 → gtfparse-2.8.1}/tests/test_write_gtf.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.8.0
3
+ Version: 2.8.1
4
4
  Summary: Parsing library for extracting data frames of genomic features from GTF files
5
5
  Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
6
6
  Project-URL: Homepage, https://github.com/openvax/gtfparse
@@ -24,7 +24,7 @@ from .read_gtf import (
24
24
  )
25
25
  from .write_gtf import write_gtf
26
26
 
27
- __version__ = "2.8.0"
27
+ __version__ = "2.8.1"
28
28
 
29
29
  __all__ = [
30
30
  "GENCODE_BIOTYPE_ALIASES",
@@ -110,9 +110,10 @@ DEFAULT_COLUMN_DTYPES = {
110
110
  def parse_with_polars_lazy(
111
111
  filepath_or_buffer, split_attributes=True, features=None, fix_quotes_columns=["attribute"]
112
112
  ):
113
- # use a global string cache so that all strings get intern'd into
114
- # a single numbering system
115
- polars.enable_string_cache()
113
+ # Categories shares categorical mappings on modern Polars. Older releases
114
+ # need the global string cache for categoricals from separate reads to match.
115
+ if not hasattr(polars, "Categories"):
116
+ polars.enable_string_cache()
116
117
  kwargs = {
117
118
  "has_header": False,
118
119
  "separator": "\t",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.8.0
3
+ Version: 2.8.1
4
4
  Summary: Parsing library for extracting data frames of genomic features from GTF files
5
5
  Author-email: Alex Rubinsteyn <alex.rubinsteyn@unc.edu>
6
6
  Project-URL: Homepage, https://github.com/openvax/gtfparse
@@ -21,6 +21,7 @@ tests/test_expand_attributes.py
21
21
  tests/test_gencode_gtf.py
22
22
  tests/test_multiple_values_for_tag_attribute.py
23
23
  tests/test_parse_gtf_lines.py
24
+ tests/test_polars_compatibility.py
24
25
  tests/test_read_stringtie_gtf.py
25
26
  tests/test_refseq_gtf.py
26
27
  tests/test_write_gtf.py
@@ -0,0 +1,51 @@
1
+ from io import StringIO
2
+
3
+ import polars
4
+ import pytest
5
+
6
+ from gtfparse import read_gtf
7
+ from gtfparse.read_gtf import parse_with_polars_lazy
8
+
9
+ GTF_TEXT = (
10
+ '1\tensembl\tgene\t10\t20\t.\t+\t.\tgene_id "g1";\n'
11
+ '2\thavana\texon\t30\t40\t.\t-\t.\tgene_id "g2";\n'
12
+ )
13
+
14
+ pytestmark = pytest.mark.filterwarnings("error::DeprecationWarning")
15
+
16
+
17
+ @pytest.mark.parametrize("result_type", ["pandas", "polars"])
18
+ def test_repeated_reads_preserve_categoricals(result_type):
19
+ for _ in range(2):
20
+ df = read_gtf(StringIO(GTF_TEXT), result_type=result_type, features={"exon"})
21
+ assert list(df["seqname"]) == ["2"]
22
+ assert list(df["feature"]) == ["exon"]
23
+ assert list(df["gene_id"]) == ["g2"]
24
+ if result_type == "polars":
25
+ assert df["seqname"].dtype == polars.Categorical
26
+ else:
27
+ assert df["seqname"].dtype.name == "category"
28
+
29
+
30
+ def test_categoricals_from_separate_lazy_reads_can_join():
31
+ left = parse_with_polars_lazy(StringIO(GTF_TEXT))
32
+ reversed_text = "\n".join(reversed(GTF_TEXT.splitlines())) + "\n"
33
+ right = parse_with_polars_lazy(StringIO(reversed_text))
34
+ keys = ["seqname", "source", "feature", "strand"]
35
+ joined = left.join(right, on=keys).sort("start").collect()
36
+
37
+ assert joined.height == 2
38
+ assert joined["start"].to_list() == [10, 30]
39
+ assert joined["start_right"].to_list() == [10, 30]
40
+ for key in keys:
41
+ assert joined[key].dtype == polars.Categorical
42
+
43
+
44
+ @pytest.mark.skipif(not hasattr(polars, "Categories"), reason="Requires modern Polars")
45
+ def test_modern_reads_do_not_toggle_global_string_cache(monkeypatch):
46
+ def fail_on_cache_toggle():
47
+ pytest.fail("Reading a GTF must not toggle the global string cache on modern Polars")
48
+
49
+ monkeypatch.setattr(polars, "enable_string_cache", fail_on_cache_toggle)
50
+ monkeypatch.setattr(polars, "disable_string_cache", fail_on_cache_toggle)
51
+ assert read_gtf(StringIO(GTF_TEXT)).height == 2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes