gtfparse 2.9.0__tar.gz → 2.9.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 (41) hide show
  1. gtfparse-2.9.1/MANIFEST.in +3 -0
  2. {gtfparse-2.9.0 → gtfparse-2.9.1}/PKG-INFO +2 -2
  3. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/__init__.py +1 -1
  4. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/read_gtf.py +4 -4
  5. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/write_gtf.py +1 -2
  6. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse.egg-info/PKG-INFO +2 -2
  7. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse.egg-info/SOURCES.txt +12 -1
  8. gtfparse-2.9.1/lint.sh +13 -0
  9. {gtfparse-2.9.0 → gtfparse-2.9.1}/pyproject.toml +6 -5
  10. gtfparse-2.9.1/test.sh +108 -0
  11. gtfparse-2.9.1/tests/__init__.py +0 -0
  12. gtfparse-2.9.1/tests/data/B16.stringtie.head.gtf +1001 -0
  13. gtfparse-2.9.1/tests/data/ensembl_grch37.head.gtf +1000 -0
  14. gtfparse-2.9.1/tests/data/ensembl_grch37.head.gtf.gz +0 -0
  15. gtfparse-2.9.1/tests/data/gencode.head.gtf +10 -0
  16. gtfparse-2.9.1/tests/data/gencode.real.head.gtf +13 -0
  17. gtfparse-2.9.1/tests/data/refseq.ucsc.small.gtf +24 -0
  18. gtfparse-2.9.1/tests/data.py +8 -0
  19. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_expand_attribute_column_false.py +1 -4
  20. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_gencode_gtf.py +4 -4
  21. {gtfparse-2.9.0 → gtfparse-2.9.1}/LICENSE +0 -0
  22. {gtfparse-2.9.0 → gtfparse-2.9.1}/README.md +0 -0
  23. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/attribute_parsing.py +0 -0
  24. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/create_missing_features.py +0 -0
  25. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse/parsing_error.py +0 -0
  26. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse.egg-info/dependency_links.txt +0 -0
  27. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse.egg-info/requires.txt +0 -0
  28. {gtfparse-2.9.0 → gtfparse-2.9.1}/gtfparse.egg-info/top_level.txt +0 -0
  29. {gtfparse-2.9.0 → gtfparse-2.9.1}/requirements.txt +0 -0
  30. {gtfparse-2.9.0 → gtfparse-2.9.1}/setup.cfg +0 -0
  31. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_attribute_values.py +0 -0
  32. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_create_missing_features.py +0 -0
  33. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_ensembl_gtf.py +0 -0
  34. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_expand_attributes.py +0 -0
  35. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_multiple_values_for_tag_attribute.py +0 -0
  36. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_parse_gtf_lines.py +0 -0
  37. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_polars_compatibility.py +0 -0
  38. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_progress.py +0 -0
  39. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_read_stringtie_gtf.py +0 -0
  40. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_refseq_gtf.py +0 -0
  41. {gtfparse-2.9.0 → gtfparse-2.9.1}/tests/test_write_gtf.py +0 -0
@@ -0,0 +1,3 @@
1
+ include lint.sh test.sh
2
+ recursive-include tests *.py
3
+ recursive-include tests/data *.gtf *.gtf.gz
@@ -1,15 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.9.0
3
+ Version: 2.9.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
+ License-Expression: Apache-2.0
6
7
  Project-URL: Homepage, https://github.com/openvax/gtfparse
7
8
  Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
8
9
  Classifier: Development Status :: 4 - Beta
9
10
  Classifier: Environment :: Console
10
11
  Classifier: Operating System :: OS Independent
11
12
  Classifier: Intended Audience :: Science/Research
12
- Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.9
@@ -24,7 +24,7 @@ from .read_gtf import (
24
24
  )
25
25
  from .write_gtf import write_gtf
26
26
 
27
- __version__ = "2.9.0"
27
+ __version__ = "2.9.1"
28
28
 
29
29
  __all__ = [
30
30
  "GENCODE_BIOTYPE_ALIASES",
@@ -197,11 +197,11 @@ def parse_gtf_and_expand_attributes(
197
197
  filepath_or_buffer, restrict_attribute_columns=None, features=None, *, progress_callback=None
198
198
  ):
199
199
  """
200
- Parse lines into column->values dictionary and then expand
200
+ Parse a GTF into a Polars DataFrame and then expand
201
201
  the 'attribute' column into multiple columns. This expansion happens
202
202
  by replacing strings of semi-colon separated key-value values in the
203
203
  'attribute' column with one column per distinct key, with a list of
204
- values for each row (using None for rows where key didn't occur).
204
+ values for each row (using empty strings for rows where the key didn't occur).
205
205
 
206
206
  Parameters
207
207
  ----------
@@ -324,7 +324,7 @@ def read_gtf(
324
324
  expand_attribute_column : bool
325
325
  Replace strings of semi-colon separated key-value values in the
326
326
  'attribute' column with one column per distinct key, with a list of
327
- values for each row (using None for rows where key didn't occur).
327
+ values for each row (using empty strings for rows where the key didn't occur).
328
328
 
329
329
  infer_biotype_column : bool
330
330
  Due to the annoying ambiguity of the second GTF column across multiple
@@ -338,7 +338,7 @@ def read_gtf(
338
338
 
339
339
  column_cast_types : dict, optional
340
340
  Dictionary mapping column names to dtypes. Will cast columns to given
341
- Polars types.
341
+ pandas-compatible types.
342
342
 
343
343
  usecols : list of str or None
344
344
  Restrict which columns are loaded to the give set. If None, then
@@ -59,8 +59,7 @@ def _attribute_expr(attribute_columns: list[str]) -> polars.Expr:
59
59
  empty string (string columns) and cannot distinguish absent from
60
60
  present-but-empty, so we treat both null and "" as absent. Values that are
61
61
  merely falsy but non-empty -- notably the string "0" -- are written and
62
- survive a round trip (this is the regression that the naive ``if value:``
63
- check in earlier drafts got wrong).
62
+ survive a round trip.
64
63
  """
65
64
  if not attribute_columns:
66
65
  return polars.lit("")
@@ -1,15 +1,15 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gtfparse
3
- Version: 2.9.0
3
+ Version: 2.9.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
+ License-Expression: Apache-2.0
6
7
  Project-URL: Homepage, https://github.com/openvax/gtfparse
7
8
  Project-URL: Bug Tracker, https://github.com/openvax/gtfparse/issues
8
9
  Classifier: Development Status :: 4 - Beta
9
10
  Classifier: Environment :: Console
10
11
  Classifier: Operating System :: OS Independent
11
12
  Classifier: Intended Audience :: Science/Research
12
- Classifier: License :: OSI Approved :: Apache Software License
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.9
@@ -1,7 +1,10 @@
1
1
  LICENSE
2
+ MANIFEST.in
2
3
  README.md
4
+ lint.sh
3
5
  pyproject.toml
4
6
  requirements.txt
7
+ test.sh
5
8
  gtfparse/__init__.py
6
9
  gtfparse/attribute_parsing.py
7
10
  gtfparse/create_missing_features.py
@@ -14,6 +17,8 @@ gtfparse.egg-info/dependency_links.txt
14
17
  gtfparse.egg-info/requires.txt
15
18
  gtfparse.egg-info/top_level.txt
16
19
  gtfparse/../requirements.txt
20
+ tests/__init__.py
21
+ tests/data.py
17
22
  tests/test_attribute_values.py
18
23
  tests/test_create_missing_features.py
19
24
  tests/test_ensembl_gtf.py
@@ -26,4 +31,10 @@ tests/test_polars_compatibility.py
26
31
  tests/test_progress.py
27
32
  tests/test_read_stringtie_gtf.py
28
33
  tests/test_refseq_gtf.py
29
- tests/test_write_gtf.py
34
+ tests/test_write_gtf.py
35
+ tests/data/B16.stringtie.head.gtf
36
+ tests/data/ensembl_grch37.head.gtf
37
+ tests/data/ensembl_grch37.head.gtf.gz
38
+ tests/data/gencode.head.gtf
39
+ tests/data/gencode.real.head.gtf
40
+ tests/data/refseq.ucsc.small.gtf
gtfparse-2.9.1/lint.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ SOURCES="gtfparse tests"
6
+
7
+ echo "Running ruff check..."
8
+ ruff check $SOURCES
9
+
10
+ echo "Running ruff format check..."
11
+ ruff format --check $SOURCES
12
+
13
+ echo "All checks passed!"
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61.0", "wheel"]
2
+ requires = ["setuptools>=77.0.3", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -7,12 +7,13 @@ name = "gtfparse"
7
7
  requires-python = ">=3.9"
8
8
  authors = [ {name="Alex Rubinsteyn", email="alex.rubinsteyn@unc.edu" } ]
9
9
  description = "Parsing library for extracting data frames of genomic features from GTF files"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
10
12
  classifiers = [
11
13
  "Development Status :: 4 - Beta",
12
14
  "Environment :: Console",
13
15
  "Operating System :: OS Independent",
14
16
  "Intended Audience :: Science/Research",
15
- "License :: OSI Approved :: Apache Software License",
16
17
  "Programming Language :: Python",
17
18
  "Programming Language :: Python :: 3",
18
19
  "Programming Language :: Python :: 3.9",
@@ -71,13 +72,13 @@ select = [
71
72
  ]
72
73
  ignore = [
73
74
  "E501", # line too long (handled by formatter)
74
- "E741", # ambiguous variable name (pre-existing in codebase)
75
- "B006", # mutable default args (pre-existing; behavior-risky to change)
75
+ "E741", # ambiguous variable names
76
+ "B006", # mutable default arguments
76
77
  "B008", # do not perform function calls in argument defaults
77
78
  "B905", # zip() without explicit strict
78
79
  "SIM108", # use ternary operator instead of if-else
79
80
  "UP007", # use X | Y for type unions (need Python 3.10+)
80
- "UP031", # %-format strings (pre-existing; out of scope for config PR)
81
+ "UP031", # %-format strings
81
82
  ]
82
83
 
83
84
  [tool.ruff.lint.per-file-ignores]
gtfparse-2.9.1/test.sh ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env bash
2
+ # Run the gtfparse test suite with a memory- and CPU-aware pytest-xdist
3
+ # worker count. Running several test suites concurrently can exhaust resources,
4
+ # so we cap workers at min(cpu_reserve, available_RAM / PER_WORKER_GB).
5
+ # xdist is optional — fall back to serial pytest when it isn't installed.
6
+ #
7
+ # Tunables (env vars):
8
+ # PER_WORKER_GB per-worker memory budget in GB (default: 1.5)
9
+ # TEST_SH_MIN floor on workers (default: 1)
10
+ # TEST_SH_MAX hard ceiling on workers (default: unset)
11
+
12
+ set -eo pipefail
13
+
14
+ PER_WORKER_GB="${PER_WORKER_GB:-1.5}"
15
+ TEST_SH_MIN="${TEST_SH_MIN:-1}"
16
+ TEST_SH_MAX="${TEST_SH_MAX:-0}"
17
+
18
+ log() { printf '[test.sh] %s\n' "$*" >&2; }
19
+
20
+ case "$(uname -s)" in
21
+ Darwin) OS=macos ;;
22
+ Linux) OS=linux ;;
23
+ *) OS=unknown ;;
24
+ esac
25
+
26
+ cpu_count() {
27
+ local n=""
28
+ if command -v getconf >/dev/null 2>&1; then
29
+ n=$(getconf _NPROCESSORS_ONLN 2>/dev/null || true)
30
+ fi
31
+ if [[ -z "$n" && "$OS" == "macos" ]]; then
32
+ n=$(sysctl -n hw.logicalcpu 2>/dev/null || true)
33
+ fi
34
+ if [[ -z "$n" && -r /proc/cpuinfo ]]; then
35
+ n=$(grep -c '^processor' /proc/cpuinfo 2>/dev/null || true)
36
+ fi
37
+ if [[ -z "$n" || "$n" -lt 1 ]]; then n=1; fi
38
+ echo "$n"
39
+ }
40
+
41
+ # Reserve cores so the system stays usable while the suite runs.
42
+ cpu_cap() {
43
+ local c="$1"
44
+ if (( c <= 1 )); then echo 1
45
+ elif (( c <= 3 )); then echo $(( c - 1 ))
46
+ else echo $(( c - 2 ))
47
+ fi
48
+ }
49
+
50
+ mac_available_bytes() {
51
+ local page_size
52
+ page_size=$(sysctl -n hw.pagesize 2>/dev/null) || return 1
53
+ vm_stat 2>/dev/null | awk -v ps="$page_size" '
54
+ /Pages free/ { gsub(/\./, "", $3); free = $3 }
55
+ /Pages inactive/ { gsub(/\./, "", $3); inactive = $3 }
56
+ /Pages speculative/ { gsub(/\./, "", $3); spec = $3 }
57
+ END { print (free + inactive + spec) * ps }
58
+ '
59
+ }
60
+
61
+ linux_available_bytes() {
62
+ [[ -r /proc/meminfo ]] || return 1
63
+ awk '
64
+ /^MemAvailable:/ { print $2 * 1024; found=1; exit }
65
+ END { if (!found) exit 1 }
66
+ ' /proc/meminfo
67
+ }
68
+
69
+ available_bytes() {
70
+ case "$OS" in
71
+ macos) mac_available_bytes ;;
72
+ linux) linux_available_bytes ;;
73
+ *) return 1 ;;
74
+ esac
75
+ }
76
+
77
+ CPUS=$(cpu_count)
78
+ CPU_CAP=$(cpu_cap "$CPUS")
79
+
80
+ avail=""
81
+ if avail=$(available_bytes 2>/dev/null) && [[ -n "$avail" ]]; then
82
+ MEM_CAP=$(awk -v b="$avail" -v g="$PER_WORKER_GB" 'BEGIN {
83
+ n = int(b / 1024^3 / g)
84
+ if (n < 1) n = 1
85
+ print n
86
+ }')
87
+ AVAIL_GB=$(awk -v b="$avail" 'BEGIN { printf "%.1f", b / 1024^3 }')
88
+ mem_note="ram_free=${AVAIL_GB}GB mem_cap=${MEM_CAP}"
89
+ else
90
+ MEM_CAP=$CPU_CAP
91
+ mem_note="ram_free=? (probe unavailable) mem_cap=cpu_cap"
92
+ fi
93
+
94
+ if (( CPU_CAP < MEM_CAP )); then WORKERS=$CPU_CAP; else WORKERS=$MEM_CAP; fi
95
+ if (( TEST_SH_MAX > 0 && WORKERS > TEST_SH_MAX )); then WORKERS=$TEST_SH_MAX; fi
96
+ if (( WORKERS < TEST_SH_MIN )); then WORKERS=$TEST_SH_MIN; fi
97
+
98
+ XDIST_FLAGS=()
99
+ if python -c "import xdist" 2>/dev/null; then
100
+ XDIST_FLAGS=(-n "$WORKERS")
101
+ log "platform=${OS} cpus=${CPUS} cpu_cap=${CPU_CAP} ${mem_note} per_worker=${PER_WORKER_GB}GB"
102
+ log "workers=${WORKERS} → exec pytest -n ${WORKERS} --cov=gtfparse/ --cov-report=term-missing tests $*"
103
+ else
104
+ log "platform=${OS} cpus=${CPUS} (pytest-xdist not installed; running serial)"
105
+ log "→ exec pytest --cov=gtfparse/ --cov-report=term-missing tests $*"
106
+ fi
107
+
108
+ exec pytest "${XDIST_FLAGS[@]}" --cov=gtfparse/ --cov-report=term-missing tests "$@"
File without changes