gtfparse 3.0.0__tar.gz → 3.0.2__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.
- {gtfparse-3.0.0/gtfparse.egg-info → gtfparse-3.0.2}/PKG-INFO +1 -1
- {gtfparse-3.0.0 → gtfparse-3.0.2}/benchmarks/README.md +5 -2
- {gtfparse-3.0.0 → gtfparse-3.0.2}/benchmarks/compare_readers.py +2 -0
- gtfparse-3.0.2/benchmarks/compare_releases.py +139 -0
- gtfparse-3.0.2/benchmarks/optimization-results.json +7147 -0
- gtfparse-3.0.2/benchmarks/optimization.md +154 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/__init__.py +1 -1
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/attribute_parsing.py +39 -48
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/read_gtf.py +60 -7
- {gtfparse-3.0.0 → gtfparse-3.0.2/gtfparse.egg-info}/PKG-INFO +1 -1
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse.egg-info/SOURCES.txt +4 -0
- gtfparse-3.0.2/tests/test_attribute_optimization.py +130 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/LICENSE +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/MANIFEST.in +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/README.md +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/benchmarks/results.json +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/_polars.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/_read_csv.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/create_missing_features.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/parsing_error.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse/write_gtf.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse.egg-info/dependency_links.txt +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse.egg-info/requires.txt +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/gtfparse.egg-info/top_level.txt +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/lint.sh +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/pyproject.toml +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/requirements.txt +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/setup.cfg +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/test.sh +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/__init__.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/B16.stringtie.head.gtf +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/ensembl_grch37.head.gtf +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/ensembl_grch37.head.gtf.gz +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/gencode.head.gtf +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/gencode.real.head.gtf +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data/refseq.ucsc.small.gtf +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/data.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_attribute_values.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_create_missing_features.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_ensembl_gtf.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_expand_attribute_column_false.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_expand_attributes.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_gencode_gtf.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_multiple_values_for_tag_attribute.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_parse_gtf_lines.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_polars_compatibility.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_progress.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_read_stringtie_gtf.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_reader.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_refseq_gtf.py +0 -0
- {gtfparse-3.0.0 → gtfparse-3.0.2}/tests/test_write_gtf.py +0 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# GTF reader backend comparison
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The 3.0.0 migration uses PyArrow for fixed-column parsing and pandas for attribute
|
|
4
4
|
processing and writing. Polars is an optional output adapter. This directory
|
|
5
5
|
contains the measurement harness and the evidence for that decision.
|
|
6
6
|
|
|
7
|
+
The follow-up [3.0.2 optimization report](optimization.md) compares the optimized
|
|
8
|
+
complete reader with both the 2.9.1 Polars and 3.0.0 Arrow/pandas releases.
|
|
9
|
+
|
|
7
10
|
## Reproduction
|
|
8
11
|
|
|
9
12
|
The recorded runs use Python 3.12.6, NumPy 2.5.3, PyArrow 25.0.1, Polars 1.44.2,
|
|
@@ -54,7 +57,7 @@ include raw attributes, filtering, selection, aliases, version casts, biotype
|
|
|
54
57
|
inference and converters; separate regressions cover streams, nullable fields,
|
|
55
58
|
comments, malformed inputs and progress/cancellation semantics.
|
|
56
59
|
|
|
57
|
-
##
|
|
60
|
+
## 3.0.0 migration results
|
|
58
61
|
|
|
59
62
|
The table shows three-run medians for equivalent pandas output. Complete load
|
|
60
63
|
time includes fixed-column reading, attribute expansion, assembly and transforms.
|
|
@@ -17,6 +17,7 @@ import sys
|
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
from time import perf_counter, process_time
|
|
19
19
|
|
|
20
|
+
import numpy as np
|
|
20
21
|
import pandas as pd
|
|
21
22
|
import pyarrow as pa
|
|
22
23
|
import pyarrow.compute as pc
|
|
@@ -257,6 +258,7 @@ def main():
|
|
|
257
258
|
"versions": {
|
|
258
259
|
"gtfparse": __version__,
|
|
259
260
|
"pandas": pd.__version__,
|
|
261
|
+
"numpy": np.__version__,
|
|
260
262
|
"polars": pl.__version__ if pl is not None else None,
|
|
261
263
|
"pyarrow": pa.__version__,
|
|
262
264
|
"python": platform.python_version(),
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Repeat complete production reads sequentially in fresh processes.
|
|
2
|
+
|
|
3
|
+
Pass --baseline LABEL ROOT for each older checkout and --python PATH for each
|
|
4
|
+
interpreter. See optimization.md for the measured corpus and reproduction.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import hashlib
|
|
9
|
+
import json
|
|
10
|
+
import os
|
|
11
|
+
import statistics
|
|
12
|
+
import subprocess
|
|
13
|
+
import sys
|
|
14
|
+
from datetime import datetime, timezone
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def summarize(records):
|
|
19
|
+
groups = {}
|
|
20
|
+
for record in records:
|
|
21
|
+
key = (
|
|
22
|
+
record["versions"]["pandas"],
|
|
23
|
+
record["path"],
|
|
24
|
+
record["release"],
|
|
25
|
+
tuple(sorted(record["versions"].items())),
|
|
26
|
+
)
|
|
27
|
+
groups.setdefault(key, []).append(record)
|
|
28
|
+
summaries = []
|
|
29
|
+
for (pandas, path, release, _versions), runs in groups.items():
|
|
30
|
+
summary = {"pandas": pandas, "input": path, "release": release, "runs": len(runs)}
|
|
31
|
+
summary["versions"] = runs[0]["versions"]
|
|
32
|
+
for name in ("wall_seconds", "cpu_seconds", "peak_rss_mib"):
|
|
33
|
+
values = [run[name] for run in runs]
|
|
34
|
+
summary[name] = {
|
|
35
|
+
"median": statistics.median(values),
|
|
36
|
+
"min": min(values),
|
|
37
|
+
"max": max(values),
|
|
38
|
+
}
|
|
39
|
+
summary["stage_medians"] = {
|
|
40
|
+
name: statistics.median(run["stages"][name] for run in runs)
|
|
41
|
+
for name in runs[0]["stages"]
|
|
42
|
+
}
|
|
43
|
+
summary["checksum"] = runs[0]["checksum"]
|
|
44
|
+
summaries.append(summary)
|
|
45
|
+
return summaries
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main():
|
|
49
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
50
|
+
parser.add_argument("inputs", nargs="+", type=Path)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"--baseline", nargs=2, action="append", default=[], metavar=("LABEL", "ROOT")
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument("--python", action="append", dest="interpreters")
|
|
55
|
+
parser.add_argument("--repeats", type=int, default=3)
|
|
56
|
+
parser.add_argument("--threads", type=int, default=4)
|
|
57
|
+
parser.add_argument("--result-type", choices=["pandas", "polars"], default="pandas")
|
|
58
|
+
parser.add_argument("--features", nargs="+")
|
|
59
|
+
parser.add_argument("--usecols", nargs="+")
|
|
60
|
+
parser.add_argument("--output", required=True, type=Path)
|
|
61
|
+
args = parser.parse_args()
|
|
62
|
+
if args.repeats < 1 or args.threads < 1:
|
|
63
|
+
parser.error("repeats and threads must be positive")
|
|
64
|
+
if len({path.name for path in args.inputs}) != len(args.inputs):
|
|
65
|
+
parser.error("input basenames must be distinct")
|
|
66
|
+
script = Path(__file__).with_name("compare_readers.py")
|
|
67
|
+
releases = [*args.baseline, ("optimized", str(script.parent.parent))]
|
|
68
|
+
expected = {}
|
|
69
|
+
records = []
|
|
70
|
+
environment = dict(os.environ, POLARS_MAX_THREADS=str(args.threads))
|
|
71
|
+
with args.output.with_suffix(".jsonl").open("w") as raw:
|
|
72
|
+
for interpreter in args.interpreters or [sys.executable]:
|
|
73
|
+
for repeat in range(1, args.repeats + 1):
|
|
74
|
+
# Rotate reader order and reverse corpus order to distribute ordering effects.
|
|
75
|
+
offset = (repeat - 1) % len(releases)
|
|
76
|
+
order = releases[offset:] + releases[:offset]
|
|
77
|
+
paths = args.inputs if repeat % 2 else args.inputs[::-1]
|
|
78
|
+
for path in paths:
|
|
79
|
+
for label, root in order:
|
|
80
|
+
command = [
|
|
81
|
+
interpreter,
|
|
82
|
+
str(script),
|
|
83
|
+
str(path),
|
|
84
|
+
"--backend",
|
|
85
|
+
"production",
|
|
86
|
+
"--library-root",
|
|
87
|
+
root,
|
|
88
|
+
"--threads",
|
|
89
|
+
str(args.threads),
|
|
90
|
+
"--result-type",
|
|
91
|
+
args.result_type,
|
|
92
|
+
]
|
|
93
|
+
for name in ("features", "usecols"):
|
|
94
|
+
value = getattr(args, name)
|
|
95
|
+
if value:
|
|
96
|
+
command.extend(["--" + name, *value])
|
|
97
|
+
run = subprocess.run(
|
|
98
|
+
command, env=environment, capture_output=True, text=True, check=True
|
|
99
|
+
)
|
|
100
|
+
record = json.loads(run.stdout)
|
|
101
|
+
key = path.name
|
|
102
|
+
content = record["checksum"], record["rows"], record["columns"]
|
|
103
|
+
if key in expected and expected[key] != content:
|
|
104
|
+
raise RuntimeError(
|
|
105
|
+
f"Reader results differ: {path}, {label}, {interpreter}"
|
|
106
|
+
)
|
|
107
|
+
expected[key] = content
|
|
108
|
+
record.update(path=path.name, release=label, repeat=repeat)
|
|
109
|
+
records.append(record)
|
|
110
|
+
raw.write(json.dumps(record, sort_keys=True) + "\n")
|
|
111
|
+
raw.flush()
|
|
112
|
+
print(
|
|
113
|
+
record["versions"]["pandas"],
|
|
114
|
+
repeat,
|
|
115
|
+
path.name,
|
|
116
|
+
label,
|
|
117
|
+
round(record["wall_seconds"], 3),
|
|
118
|
+
round(record["peak_rss_mib"]),
|
|
119
|
+
flush=True,
|
|
120
|
+
)
|
|
121
|
+
result = {
|
|
122
|
+
"description": "Complete production readers; imports/checksums outside wall time; sequential fresh processes",
|
|
123
|
+
"date": datetime.now(timezone.utc).isoformat(),
|
|
124
|
+
"threads": args.threads,
|
|
125
|
+
"inputs": {
|
|
126
|
+
path.name: {
|
|
127
|
+
"bytes": path.stat().st_size,
|
|
128
|
+
"sha256": hashlib.sha256(path.read_bytes()).hexdigest(),
|
|
129
|
+
}
|
|
130
|
+
for path in args.inputs
|
|
131
|
+
},
|
|
132
|
+
"summaries": summarize(records),
|
|
133
|
+
"measurements": records,
|
|
134
|
+
}
|
|
135
|
+
args.output.write_text(json.dumps(result, indent=2) + "\n")
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if __name__ == "__main__":
|
|
139
|
+
main()
|