gtfparse 2.4.1__tar.gz → 2.6.0__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 (25) hide show
  1. {gtfparse-2.4.1 → gtfparse-2.6.0}/PKG-INFO +7 -7
  2. {gtfparse-2.4.1 → gtfparse-2.6.0}/README.md +1 -3
  3. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse/__init__.py +1 -1
  4. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse/read_gtf.py +22 -21
  5. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse.egg-info/PKG-INFO +7 -7
  6. gtfparse-2.6.0/gtfparse.egg-info/requires.txt +3 -0
  7. {gtfparse-2.4.1 → gtfparse-2.6.0}/pyproject.toml +1 -1
  8. gtfparse-2.6.0/requirements.txt +3 -0
  9. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_ensembl_gtf.py +1 -1
  10. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_read_stringtie_gtf.py +1 -1
  11. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_refseq_gtf.py +1 -1
  12. gtfparse-2.4.1/gtfparse.egg-info/requires.txt +0 -2
  13. gtfparse-2.4.1/requirements.txt +0 -2
  14. {gtfparse-2.4.1 → gtfparse-2.6.0}/LICENSE +0 -0
  15. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse/attribute_parsing.py +0 -0
  16. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse/create_missing_features.py +0 -0
  17. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse/parsing_error.py +0 -0
  18. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse.egg-info/SOURCES.txt +0 -0
  19. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse.egg-info/dependency_links.txt +0 -0
  20. {gtfparse-2.4.1 → gtfparse-2.6.0}/gtfparse.egg-info/top_level.txt +0 -0
  21. {gtfparse-2.4.1 → gtfparse-2.6.0}/setup.cfg +0 -0
  22. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_create_missing_features.py +0 -0
  23. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_expand_attributes.py +0 -0
  24. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_multiple_values_for_tag_attribute.py +0 -0
  25. {gtfparse-2.4.1 → gtfparse-2.6.0}/tests/test_parse_gtf_lines.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.4.1
3
+ Version: 2.6.0
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
@@ -15,12 +15,12 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
15
  Requires-Python: >=3.7
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: polars<0.21.0,>=0.20.2
19
- Requires-Dist: pyarrow<14.1.0,>=14.0.2
18
+ Requires-Dist: polars>=0.20.2
19
+ Requires-Dist: pyarrow>=18.0.0
20
+ Requires-Dist: pandas>=2.1.0
21
+ Dynamic: license-file
20
22
 
21
- <!--
22
- [![Build Status](https://travis-ci.org/openvax/gtfparse.svg?branch=master)](https://travis-ci.org/openvax/gtfparse)
23
- -->
23
+ [![Tests](https://github.com/openvax/gtfparse/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
24
24
  [![Coverage Status](https://coveralls.io/repos/openvax/gtfparse/badge.svg?branch=master&service=github)](https://coveralls.io/github/openvax/gtfparse?branch=master)
25
25
  <a href="https://pypi.python.org/pypi/gtfparse/">
26
26
  <img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
@@ -1,6 +1,4 @@
1
- <!--
2
- [![Build Status](https://travis-ci.org/openvax/gtfparse.svg?branch=master)](https://travis-ci.org/openvax/gtfparse)
3
- -->
1
+ [![Tests](https://github.com/openvax/gtfparse/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
4
2
  [![Coverage Status](https://coveralls.io/repos/openvax/gtfparse/badge.svg?branch=master&service=github)](https://coveralls.io/github/openvax/gtfparse?branch=master)
5
3
  <a href="https://pypi.python.org/pypi/gtfparse/">
6
4
  <img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
@@ -21,7 +21,7 @@ from .read_gtf import (
21
21
  REQUIRED_COLUMNS,
22
22
  )
23
23
 
24
- __version__ = "2.4.1"
24
+ __version__ = "2.6.0"
25
25
 
26
26
  __all__ = [
27
27
  "__version__",
@@ -12,8 +12,6 @@
12
12
 
13
13
  import logging
14
14
  from os.path import exists
15
- from io import StringIO
16
- import gzip
17
15
 
18
16
  import polars
19
17
 
@@ -103,15 +101,18 @@ def parse_with_polars_lazy(
103
101
  separator="\t",
104
102
  comment_prefix="#",
105
103
  null_values=".",
106
- dtypes=DEFAULT_COLUMN_DTYPES)
104
+ schema_overrides=DEFAULT_COLUMN_DTYPES)
107
105
  try:
108
106
  df = polars.read_csv(
109
107
  filepath_or_buffer,
110
108
  new_columns=REQUIRED_COLUMNS,
111
109
  **kwargs).lazy()
112
- except polars.ShapeError:
110
+ except polars.exceptions.ShapeError:
113
111
  raise ParsingError("Wrong number of columns")
114
112
 
113
+ # Drop empty lines that may appear as all-null rows
114
+ df = df.filter(polars.col("seqname").is_not_null())
115
+
115
116
  df = df.with_columns([
116
117
  polars.col("frame").fill_null(0),
117
118
  polars.col("attribute").str.replace_all('"', "'")
@@ -253,11 +254,11 @@ def read_gtf(
253
254
  else:
254
255
  result_df = parse_gtf(result_df, features=features)
255
256
 
256
-
257
+ # converting back to pandas here because Polars bugs manifest
258
+ # as `pyo3_runtime.PanicException: assertion `left == right` failed: impl error`
259
+ # and are generally insane to chase down
260
+ result_df = result_df.to_pandas()
257
261
  if column_converters or column_cast_types:
258
- # transform columns with user-specified functions and/or cast them to user-specified types
259
- polars_expressions = []
260
-
261
262
  def wrap_to_always_accept_none(f):
262
263
  def wrapped_fn(x):
263
264
  if x is None or x == "":
@@ -268,17 +269,16 @@ def read_gtf(
268
269
 
269
270
  column_names = set(column_converters.keys()).union(column_cast_types.keys())
270
271
  for column_name in column_names:
271
- e = polars.col(column_name)
272
+
272
273
  if column_name in column_converters:
273
- column_fn = column_converters[column_name]
274
- e = e.map_elements(wrap_to_always_accept_none(column_fn))
274
+ column_fn = wrap_to_always_accept_none(
275
+ column_converters[column_name])
276
+ result_df[column_name] = result_df[column_name].apply(column_fn)
275
277
 
276
278
  if column_name in column_cast_types:
277
279
  column_type = column_cast_types[column_name]
278
- e = e.cast(column_type)
279
- polars_expressions.append(e)
280
- result_df = result_df.with_columns(polars_expressions)
281
-
280
+ result_df[column_name] = result_df[column_name].astype(column_type)
281
+
282
282
  # Hackishly infer whether the values in the 'source' column of this GTF
283
283
  # are actually representing a biotype by checking for the most common
284
284
  # gene_biotype and transcript_biotype value 'protein_coding'
@@ -292,20 +292,21 @@ def read_gtf(
292
292
  # gene_biotype)
293
293
  if "gene_biotype" not in column_names:
294
294
  logging.info("Using column 'source' to replace missing 'gene_biotype'")
295
- result_df = result_df.with_columns([polars.col("source").alias("gene_biotype")])
295
+ result_df['gene_biotype'] = result_df['source']
296
296
  if "transcript_biotype" not in column_names:
297
297
  logging.info("Using column 'source' to replace missing 'transcript_biotype'")
298
- result_df = result_df.with_columns([polars.col("source").alias("transcript_biotype")])
299
-
298
+ result_df['transcript_biotype'] = result_df['source']
299
+
300
300
  if usecols is not None:
301
301
  column_names = set(result_df.columns)
302
302
  valid_columns = [c for c in usecols if c in column_names]
303
- result_df = result_df.select(valid_columns)
303
+ result_df = result_df[valid_columns]
304
304
 
305
+ result = None
305
306
  if result_type == "pandas":
306
- result = result_df.to_pandas()
307
- elif result_type == "polars":
308
307
  result = result_df
308
+ elif result_type == "polars":
309
+ result = polars.from_pandas(result_df)
309
310
  elif result_type == "dict":
310
311
  result = result_df.to_dict()
311
312
  return result
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.4.1
3
+ Version: 2.6.0
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
@@ -15,12 +15,12 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
15
15
  Requires-Python: >=3.7
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: polars<0.21.0,>=0.20.2
19
- Requires-Dist: pyarrow<14.1.0,>=14.0.2
18
+ Requires-Dist: polars>=0.20.2
19
+ Requires-Dist: pyarrow>=18.0.0
20
+ Requires-Dist: pandas>=2.1.0
21
+ Dynamic: license-file
20
22
 
21
- <!--
22
- [![Build Status](https://travis-ci.org/openvax/gtfparse.svg?branch=master)](https://travis-ci.org/openvax/gtfparse)
23
- -->
23
+ [![Tests](https://github.com/openvax/gtfparse/actions/workflows/tests.yml/badge.svg)](https://github.com/openvax/gtfparse/actions/workflows/tests.yml)
24
24
  [![Coverage Status](https://coveralls.io/repos/openvax/gtfparse/badge.svg?branch=master&service=github)](https://coveralls.io/github/openvax/gtfparse?branch=master)
25
25
  <a href="https://pypi.python.org/pypi/gtfparse/">
26
26
  <img src="https://img.shields.io/pypi/v/gtfparse.svg?maxAge=1000" alt="PyPI" />
@@ -0,0 +1,3 @@
1
+ polars>=0.20.2
2
+ pyarrow>=18.0.0
3
+ pandas>=2.1.0
@@ -24,4 +24,4 @@ packages = ["gtfparse"]
24
24
 
25
25
  [project.urls]
26
26
  "Homepage" = "https://github.com/openvax/gtfparse"
27
- "Bug Tracker" = "https://github.com/openvax/gtfparse"
27
+ "Bug Tracker" = "https://github.com/openvax/gtfparse"
@@ -0,0 +1,3 @@
1
+ polars>=0.20.2
2
+ pyarrow>=18.0.0
3
+ pandas>=2.1.0
@@ -1,6 +1,6 @@
1
- from data import data_path
2
1
  from gtfparse import read_gtf
3
2
 
3
+ from .data import data_path
4
4
 
5
5
  ENSEMBL_GTF_PATH = data_path("ensembl_grch37.head.gtf")
6
6
 
@@ -1,5 +1,5 @@
1
1
  from gtfparse import read_gtf
2
- from data import data_path
2
+ from .data import data_path
3
3
 
4
4
  B16_GTF_PATH = data_path("B16.stringtie.head.gtf")
5
5
 
@@ -1,5 +1,5 @@
1
1
  from gtfparse import read_gtf
2
- from data import data_path
2
+ from .data import data_path
3
3
 
4
4
  REFSEQ_GTF_PATH = data_path("refseq.ucsc.small.gtf")
5
5
 
@@ -1,2 +0,0 @@
1
- polars<0.21.0,>=0.20.2
2
- pyarrow<14.1.0,>=14.0.2
@@ -1,2 +0,0 @@
1
- polars>=0.20.2,<0.21.0
2
- pyarrow>=14.0.2,<14.1.0
File without changes
File without changes