gffbase 0.1.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 (62) hide show
  1. gffbase-0.1.0/LICENSE +200 -0
  2. gffbase-0.1.0/MANIFEST.in +33 -0
  3. gffbase-0.1.0/PKG-INFO +355 -0
  4. gffbase-0.1.0/README.md +291 -0
  5. gffbase-0.1.0/pyproject.toml +190 -0
  6. gffbase-0.1.0/python/gffbase/__init__.py +76 -0
  7. gffbase-0.1.0/python/gffbase/_bins.py +43 -0
  8. gffbase-0.1.0/python/gffbase/_pyfallback/__init__.py +23 -0
  9. gffbase-0.1.0/python/gffbase/_pyfallback/attributes.py +135 -0
  10. gffbase-0.1.0/python/gffbase/_pyfallback/parser.py +417 -0
  11. gffbase-0.1.0/python/gffbase/create_db.py +102 -0
  12. gffbase-0.1.0/python/gffbase/dialect.py +75 -0
  13. gffbase-0.1.0/python/gffbase/exceptions.py +66 -0
  14. gffbase-0.1.0/python/gffbase/feature.py +510 -0
  15. gffbase-0.1.0/python/gffbase/gffwriter.py +103 -0
  16. gffbase-0.1.0/python/gffbase/helpers.py +39 -0
  17. gffbase-0.1.0/python/gffbase/ingest.py +574 -0
  18. gffbase-0.1.0/python/gffbase/interface.py +1417 -0
  19. gffbase-0.1.0/python/gffbase/iterators.py +108 -0
  20. gffbase-0.1.0/python/gffbase/merge_criteria.py +78 -0
  21. gffbase-0.1.0/python/gffbase/parser.py +175 -0
  22. gffbase-0.1.0/python/gffbase/schema.py +285 -0
  23. gffbase-0.1.0/python/gffbase/sqlite_export.py +159 -0
  24. gffbase-0.1.0/rust/Cargo.lock +239 -0
  25. gffbase-0.1.0/rust/Cargo.toml +34 -0
  26. gffbase-0.1.0/rust/README.md +291 -0
  27. gffbase-0.1.0/rust/src/attributes.rs +232 -0
  28. gffbase-0.1.0/rust/src/dialect.rs +110 -0
  29. gffbase-0.1.0/rust/src/escape.rs +77 -0
  30. gffbase-0.1.0/rust/src/lib.rs +269 -0
  31. gffbase-0.1.0/rust/src/parser.rs +420 -0
  32. gffbase-0.1.0/rust/src/validate.rs +355 -0
  33. gffbase-0.1.0/tests/__init__.py +16 -0
  34. gffbase-0.1.0/tests/conftest.py +56 -0
  35. gffbase-0.1.0/tests/data/hierarchy.gff3 +9 -0
  36. gffbase-0.1.0/tests/data/simple.gff3 +7 -0
  37. gffbase-0.1.0/tests/data/simple.gtf +3 -0
  38. gffbase-0.1.0/tests/data/synthesize.gtf +5 -0
  39. gffbase-0.1.0/tests/test_api_surface_completeness.py +544 -0
  40. gffbase-0.1.0/tests/test_batched_api.py +301 -0
  41. gffbase-0.1.0/tests/test_corrupted_inputs.py +425 -0
  42. gffbase-0.1.0/tests/test_coverage_gaps.py +807 -0
  43. gffbase-0.1.0/tests/test_dispatcher_and_routing.py +272 -0
  44. gffbase-0.1.0/tests/test_dispatcher_handoff.py +226 -0
  45. gffbase-0.1.0/tests/test_engine_equivalence.py +51 -0
  46. gffbase-0.1.0/tests/test_feature_class.py +434 -0
  47. gffbase-0.1.0/tests/test_featuredb_basic.py +96 -0
  48. gffbase-0.1.0/tests/test_featuredb_execute.py +67 -0
  49. gffbase-0.1.0/tests/test_featuredb_export.py +71 -0
  50. gffbase-0.1.0/tests/test_featuredb_hierarchy.py +134 -0
  51. gffbase-0.1.0/tests/test_featuredb_invariants.py +98 -0
  52. gffbase-0.1.0/tests/test_featuredb_region.py +133 -0
  53. gffbase-0.1.0/tests/test_helpers_and_misc.py +156 -0
  54. gffbase-0.1.0/tests/test_ingest_basic.py +232 -0
  55. gffbase-0.1.0/tests/test_iterators_writer.py +140 -0
  56. gffbase-0.1.0/tests/test_merge_criteria.py +108 -0
  57. gffbase-0.1.0/tests/test_ncbi_compliance.py +395 -0
  58. gffbase-0.1.0/tests/test_parser_basics.py +96 -0
  59. gffbase-0.1.0/tests/test_parser_malformed.py +175 -0
  60. gffbase-0.1.0/tests/test_spatial_parity.py +262 -0
  61. gffbase-0.1.0/tests/test_synthesis_and_mutation.py +310 -0
  62. gffbase-0.1.0/tests/test_vectorized_edges.py +239 -0
gffbase-0.1.0/LICENSE ADDED
@@ -0,0 +1,200 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept support,
167
+ warranty, indemnity, or other liability obligations and/or rights
168
+ consistent with this License. However, in accepting such obligations,
169
+ You may act only on Your own behalf and on Your sole responsibility,
170
+ not on behalf of any other Contributor, and only if You agree to
171
+ indemnify, defend, and hold each Contributor harmless for any
172
+ liability incurred by, or claims asserted against, such Contributor
173
+ by reason of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ APPENDIX: How to apply the Apache License to your work.
178
+
179
+ To apply the Apache License to your work, attach the following
180
+ boilerplate notice, with the fields enclosed by brackets "[]"
181
+ replaced with your own identifying information. (Don't include
182
+ the brackets!) The text should be enclosed in the appropriate
183
+ comment syntax for the file format. We also recommend that a
184
+ file or class name and description of purpose be included on the
185
+ same "printed page" as the copyright notice for easier
186
+ identification within third-party archives.
187
+
188
+ Copyright 2026 Kuan-Hao Chao
189
+
190
+ Licensed under the Apache License, Version 2.0 (the "License");
191
+ you may not use this file except in compliance with the License.
192
+ You may obtain a copy of the License at
193
+
194
+ http://www.apache.org/licenses/LICENSE-2.0
195
+
196
+ Unless required by applicable law or agreed to in writing, software
197
+ distributed under the License is distributed on an "AS IS" BASIS,
198
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
199
+ See the License for the specific language governing permissions and
200
+ limitations under the License.
@@ -0,0 +1,33 @@
1
+ include pyproject.toml
2
+ include README.md
3
+ include LICENSE
4
+ include MANIFEST.in
5
+
6
+ # Rust crate (required for sdist โ†’ wheel rebuild on user's machine)
7
+ include rust/Cargo.toml
8
+ include rust/Cargo.lock
9
+ recursive-include rust/src *.rs
10
+
11
+ # Python source tree (also covered by [tool.maturin] python-source).
12
+ recursive-include python/gffbase *.py
13
+ recursive-include python/gffbase *.pyi
14
+
15
+ # Tests + fixtures bundled so `pytest` works against an installed sdist.
16
+ recursive-include tests *.py
17
+ recursive-include tests/data *.gff3 *.gtf
18
+
19
+ # Developer documentation (Phase reports + summaries).
20
+ include PHASE3_PARSER_SUMMARY.md
21
+ include PHASE4_INGESTION_SUMMARY.md
22
+ include PHASE5_API_SUMMARY.md
23
+ include PHASE6_BENCHMARK_REPORT.md
24
+ include PHASE7_REMEDIATION_REPORT.md
25
+ include PHASE8_PACKAGING_SUMMARY.md
26
+
27
+ # Excludes โ€” we never want compiled extensions / caches in the sdist.
28
+ prune target
29
+ prune **/__pycache__
30
+ prune **/.pytest_cache
31
+ prune **/.mypy_cache
32
+ prune **/.ruff_cache
33
+ global-exclude *.pyc *.so *.dylib *.dll
gffbase-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,355 @@
1
+ Metadata-Version: 2.4
2
+ Name: gffbase
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Programming Language :: Rust
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
24
+ Classifier: Topic :: Database
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Typing :: Typed
27
+ Requires-Dist: duckdb>=1.0
28
+ Requires-Dist: pyarrow>=14
29
+ Requires-Dist: psutil>=5 ; extra == 'bench'
30
+ Requires-Dist: memory-profiler>=0.61 ; extra == 'bench'
31
+ Requires-Dist: gffutils>=0.13 ; extra == 'bench'
32
+ Requires-Dist: pytest>=7 ; extra == 'dev'
33
+ Requires-Dist: hypothesis>=6 ; extra == 'dev'
34
+ Requires-Dist: psutil>=5 ; extra == 'dev'
35
+ Requires-Dist: ruff>=0.4 ; extra == 'dev'
36
+ Requires-Dist: mypy>=1.8 ; extra == 'dev'
37
+ Requires-Dist: maturin>=1.5,<2.0 ; extra == 'dev'
38
+ Requires-Dist: mkdocs>=1.6 ; extra == 'docs'
39
+ Requires-Dist: mkdocs-material>=9.5 ; extra == 'docs'
40
+ Requires-Dist: mkdocstrings[python]>=0.25 ; extra == 'docs'
41
+ Requires-Dist: mkdocs-include-markdown-plugin>=6.2 ; extra == 'docs'
42
+ Requires-Dist: pymdown-extensions>=10.7 ; extra == 'docs'
43
+ Requires-Dist: pytest>=7 ; extra == 'test'
44
+ Requires-Dist: hypothesis>=6 ; extra == 'test'
45
+ Requires-Dist: pytest-cov>=4 ; extra == 'test'
46
+ Provides-Extra: bench
47
+ Provides-Extra: dev
48
+ Provides-Extra: docs
49
+ Provides-Extra: test
50
+ License-File: LICENSE
51
+ Summary: GFFBase โ€” Rust-accelerated GFF3/GTF parser with a DuckDB-backed storage engine and a drop-in gffutils-compatible Python API.
52
+ Keywords: gff,gff3,gtf,gencode,bioinformatics,genomics,annotation,duckdb,rust,pyo3,parser,feature-database
53
+ Home-Page: https://github.com/Kuanhao-Chao/gffbase
54
+ Author-email: Kuan-Hao Chao <kuanhao.chao@gmail.com>
55
+ License: Apache-2.0
56
+ Requires-Python: >=3.9
57
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
58
+ Project-URL: Changelog, https://github.com/Kuanhao-Chao/gffbase/releases
59
+ Project-URL: Documentation, https://kuanhao-chao.github.io/gffbase/
60
+ Project-URL: Homepage, https://github.com/Kuanhao-Chao/gffbase
61
+ Project-URL: Issues, https://github.com/Kuanhao-Chao/gffbase/issues
62
+ Project-URL: Source, https://github.com/Kuanhao-Chao/gffbase
63
+
64
+ # GFFBase
65
+
66
+ [![PyPI](https://img.shields.io/pypi/v/gffbase.svg)](https://pypi.org/project/gffbase/)
67
+ [![Python](https://img.shields.io/pypi/pyversions/gffbase.svg)](https://pypi.org/project/gffbase/)
68
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
69
+ [![Tests](https://img.shields.io/badge/tests-523%20passing-brightgreen.svg)](#testing)
70
+ [![Coverage](https://img.shields.io/badge/coverage-99.19%25-brightgreen.svg)](#testing)
71
+ [![Validated](https://img.shields.io/badge/validated-GENCODE%20%7C%20RefSeq%20%7C%20MANE%20%7C%20CHESS%203-blue.svg)](#-comprehensive-human-genome-annotations--validated-across-every-canonical-corpus)
72
+
73
+ ---
74
+
75
+ ## What is GFFBase?
76
+
77
+ **GFFBase is a high-performance genomic-annotation engine combining a
78
+ SIMD Rust parser, a DuckDB columnar backend, and a zero-copy PyArrow
79
+ interface โ€” purpose-built for whole-genome-scale ingest and bulk
80
+ machine-learning feature extraction, while remaining a drop-in
81
+ successor to [`gffutils`](https://github.com/daler/gffutils).**
82
+
83
+ A SIMD Rust+PyO3 parser feeds DuckDB's columnar storage through
84
+ record-batch Arrow handoffs. A smart query router auto-picks an
85
+ R-tree or B-tree spatial index per query, and a closure-cache /
86
+ recursive-CTE relational dispatcher selects the right strategy based
87
+ on the corpus's actual hierarchy depth. The full `FeatureDB` /
88
+ `Feature` / `create_db` / `DataIterator` / `GFFWriter` /
89
+ `merge_criteria` legacy API is preserved verbatim โ€” most users
90
+ migrate by changing one import line.
91
+
92
+ ### Three reasons it matters
93
+
94
+ 1. **๐Ÿš€ โ‰ฅ 32ร— faster GENCODE GTF ingest** (v49, 6.07 M lines) โ€” and
95
+ **mathematically more efficient**: legacy needs a Python loop +
96
+ ~5 million correlated SQLite subqueries to *invent* the missing
97
+ gene/transcript rows, while gffbase does the same work in two
98
+ set-based DuckDB `GROUP BY` aggregations + one recursive CTE.
99
+ *([Proven by a same-release GTF/GFF3 head-to-head](#-comprehensive-human-genome-annotations--validated-across-every-canonical-corpus))*
100
+ 2. **โšก 36.68ร— faster bulk ML extraction** โ€” `children_batched(format='arrow')`
101
+ returns 50 000 transcripts โ†’ 1.6 M exons as a zero-copy PyArrow
102
+ table in **1.16 s**. No Python `Feature` objects, ever. *([How?](#-the-killer-feature--zero-copy-pyarrow-for-ml-pipelines))*
103
+ 3. **๐Ÿ›ก๏ธ Validated NCBI compliance** โ€” all four canonical human-genome
104
+ annotations (GENCODE / RefSeq / MANE / CHESS 3) ingest cleanly with
105
+ **zero strict-mode warnings**. RefSeq's split-CDS duplicate-ID
106
+ convention is handled automatically.
107
+
108
+ ---
109
+
110
+ ## โšก Comprehensive Human Genome Annotations โ€” validated across every canonical corpus
111
+
112
+ Validated head-to-head against legacy `gffutils` on the four canonical
113
+ human-genome annotation sources, including the **GENCODE v49 GTF and
114
+ GFF3 versions of the same release** โ€” a same-biology, same-features,
115
+ different-format pairing that exposes the GTF Synthesis Advantage in
116
+ its purest form:
117
+
118
+ | Corpus | Format | Lines | gffbase ingest | legacy ingest | **speedup** | spatial qps | batched (5 k anchors) |
119
+ | ------------------------ | :----: | ---------: | -------------: | ------------: | ------------: | ----------: | --------------------: |
120
+ | **GENCODE v49** (basic) | GTF | 6,068,892 | **4 min 37 s** | โ‰ฅ 2 hr 30 min[^1] | **๐Ÿš€ โ‰ฅ 32ร—** | **1,204** | 172 ms / 596 k desc |
121
+ | **GENCODE v49** (basic) | GFF3 | 6,066,054 | **6 min 7 s** | 11 min 23 s | **1.86ร—** | **1,292** | 422 ms / 1.93 M desc |
122
+ | **RefSeq GRCh38.p14** | GFF3 | 4,932,571 | **4 min 12 s**[^2] | 6 min 5 s | **1.45ร—** | **1,011** | 263 ms / 999 k desc |
123
+ | **MANE v1.5** (Ensembl) | GFF3 | 524,834 | **21.6 s** | 45.1 s | **2.09ร—** | **1,766** | 78 ms / 156 k desc |
124
+ | **CHESS 3.1.3** | GFF3 | 2,761,061 | **53.6 s** | 2 min 13.1 s | **2.48ร—** | **1,175** | 91 ms / 161 k desc |
125
+
126
+ [^1]: Legacy `gffutils.create_db()` on GENCODE v49 GTF (6.07 M lines) hits the bench's safety-valve cap (75 min). The reported wall is a conservative 2ร— extrapolation โ€” the canonical GENCODE v45 GTF (2.0 M lines, 3ร— smaller) ran uncapped at **3,582 s (59 min 42 s)** on the same hardware, so the v49 wall is well past 2 hours. See [Performance Comparison ยง"GTF Synthesis Advantage"](PERFORMANCE_COMPARISON.md#-the-gtf-synthesis-advantage--proven-by-a-same-release-head-to-head) for the formal cost model.
127
+ [^2]: Result of the v0.1.0 ingest-pipeline optimization โ€” the same RefSeq corpus used to take 7 min 49 s before the GFF3 path was re-architected to stamp `seqid_y` and `bbox` inline during the Arrow batch INSERT.
128
+
129
+ **The same biological release, ingested in two different formats, by
130
+ two different engines** โ€” that's the load-bearing comparison. Legacy
131
+ GFF3 ingest finishes in 11 min because every parent edge is explicit;
132
+ legacy GTF ingest takes hours because the parent rows have to be
133
+ *invented* from the data (one Python โ†” SQLite round-trip per missing
134
+ row). gffbase replaces those millions of round-trips with two
135
+ set-based DuckDB `GROUP BY` aggregations + one recursive CTE โ€” the
136
+ **same code path** runs for GTF and GFF3, which is why the gffbase
137
+ column barely shifts (4 min 37 s โ†’ 6 min 7 s) between the two rows
138
+ while the legacy column balloons by 13ร—โ€“20ร—.
139
+
140
+ **Robustness:** every corpus ingests cleanly with **zero strict-mode
141
+ warnings** from the NCBI-spec-hardened Rust parser (9 enforced rules,
142
+ line-numbered `GFFFormatError`, opt-in non-strict mode). RefSeq's
143
+ notorious duplicate-`ID=cds-NP_xxx` convention (split CDS segments) is
144
+ handled transparently โ€” gffbase mirrors
145
+ `gffutils.merge_strategy="create_unique"` automatically and records the
146
+ remap in the `duplicates` table. No config knobs to flip.
147
+
148
+ ๐Ÿ“Š Full reproducible numbers + per-corpus root-cause analysis:
149
+ [`PERFORMANCE_COMPARISON.md`](PERFORMANCE_COMPARISON.md). Re-run via
150
+ `python benchmarks/06_mega.py --legacy-timeout 900`.
151
+
152
+ ---
153
+
154
+ ## ๐Ÿš€ The Killer Feature โ€” zero-copy PyArrow for ML pipelines
155
+
156
+ Modern ML genomics pipelines have one shape: **pull every exon for
157
+ 50 000 transcripts, push the column-oriented table into a tensor,
158
+ train.** Legacy `gffutils` forces a per-feature Python loop โ€”
159
+ constructing 1.6 M throwaway `Feature` objects per pull, which crushes
160
+ both wall time and memory. gffbase bypasses Python entirely with a
161
+ single batched call that returns DuckDB's internal Arrow buffers
162
+ directly:
163
+
164
+ ```python
165
+ # 50 000 transcript IDs โ†’ every exon, in one query.
166
+ # Returns a zero-copy pyarrow.Table โ€” no Python `Feature` object
167
+ # is constructed at any layer.
168
+ exons = db.children_batched(
169
+ transcript_ids,
170
+ featuretype="exon",
171
+ format="arrow", # or "df" / "polars"
172
+ )
173
+
174
+ # Hand off directly to PyTorch / Hugging Face datasets / JAX / Lance.
175
+ import torch
176
+ starts = torch.from_numpy(exons.column("start").to_numpy())
177
+ ends = torch.from_numpy(exons.column("end").to_numpy())
178
+ # The "anchor" column carries the input id for each row, so you can
179
+ # reconstruct per-transcript groups without re-issuing N queries.
180
+ ```
181
+
182
+ **Numbers for that one call** (50 000 transcripts, GENCODE basic
183
+ annotation, returning 1.6 M exon rows):
184
+
185
+ | Path | Wall | vs legacy |
186
+ | ----------------------------------------- | ----------: | ---------------- |
187
+ | gffbase `children_batched(format='arrow')`| **1.16 s**| **36.68ร— faster**|
188
+ | legacy `gffutils` row-by-row loop | 42.55 s | 1.0ร— (baseline) |
189
+ | gffbase row-by-row loop | โ‰ฅ 642 s | 0.07ร— *(slower!)*|
190
+
191
+ This is **the** reason GFFBase exists. Iterating
192
+ `for x in ids: db.children(x)` with DuckDB pays vectorization startup
193
+ per call and is *slower* than legacy's SQLite row-by-row path โ€” but
194
+ the batched API obliterates both row-by-row paths because it issues
195
+ one set-based SQL query and avoids constructing any Python `Feature`
196
+ objects whatsoever.
197
+
198
+ `region_batched(...)` and `parents_batched(...)` have the same
199
+ zero-copy contract for spatial and parent workloads.
200
+
201
+ ---
202
+
203
+ ## ๐Ÿ“ฆ Installation
204
+
205
+ ```bash
206
+ pip install gffbase
207
+ ```
208
+
209
+ Universal `abi3-py39` wheels โ€” single binary per arch covers CPython
210
+ 3.9 โ†’ 3.13. No Rust toolchain required at install time.
211
+
212
+ For source/dev installs (Rust โ‰ฅ 1.69 + maturin):
213
+
214
+ ```bash
215
+ pip install -e .[dev]
216
+ maturin develop --release
217
+ ```
218
+
219
+ ---
220
+
221
+ ## ๐Ÿƒ Quick start โ€” row-by-row (drop-in for `gffutils`)
222
+
223
+ ```python
224
+ from gffbase import create_db
225
+
226
+ # 1. Ingest a GTF/GFF3 in seconds (auto-detects format, gzipped OK).
227
+ db = create_db("gencode.v49.chr_patch_hapl_scaff.basic.annotation.gtf.gz",
228
+ "gencode.duckdb", force=True)
229
+
230
+ # 2. Walk a single gene's hierarchy.
231
+ for tx in db.children("ENSG00000139618", level=1, featuretype="transcript"):
232
+ print(tx.id, tx.start, tx.end)
233
+
234
+ # 3. Spatial overlap query โ€” uses the per-seqid R-tree under the hood.
235
+ for f in db.region("chr17:43044295-43125483", featuretype="exon"):
236
+ print(f)
237
+ ```
238
+
239
+ If you're migrating from `gffutils`, change one line:
240
+
241
+ ```python
242
+ import gffbase as gffutils # one-line alias migration
243
+ db = gffutils.create_db(...) # everything else identical
244
+ ```
245
+
246
+ (But please read the [Migration Guide](MIGRATION.md) first โ€” it has
247
+ **one** important note about ML loops.)
248
+
249
+ ---
250
+
251
+ ## ๐Ÿค– Quick start โ€” vectorized for ML
252
+
253
+ ```python
254
+ from gffbase import FeatureDB
255
+
256
+ db = FeatureDB("gencode.duckdb")
257
+
258
+ # Pull every exon for 50 000 transcripts โ€” one set-based SQL query.
259
+ exons = db.children_batched(
260
+ transcript_ids, # iterable of 50 000 IDs
261
+ featuretype="exon",
262
+ format="arrow", # "df" / "polars" also supported
263
+ )
264
+ # exons is a pyarrow.Table sharing memory with DuckDB. No copies.
265
+
266
+ # Spatial: "for each ATAC-seq peak, find every overlapping CDS."
267
+ peaks = [("chr1", 100_000, 110_000), ("chr1", 200_000, 210_000), ...]
268
+ overlaps = db.region_batched(peaks, featuretype="CDS", format="arrow")
269
+ ```
270
+
271
+ See the [Machine Learning Workflows
272
+ Cookbook](docs/cookbooks/machine_learning_workflows.md) for end-to-end
273
+ pipelines with PyTorch and Hugging Face `datasets`.
274
+
275
+ ---
276
+
277
+ ## โœจ What's inside
278
+
279
+ - **Rust + PyO3 parser** โ€” SIMD line/tab splitting, lazy URL-decoding,
280
+ GTF semicolon-in-quotes safe, gzipped input transparent. Hardened
281
+ against the NCBI GFF3 spec (line-numbered `GFFFormatError`,
282
+ strict / non-strict modes, 9 enforced rules).
283
+ - **DuckDB columnar storage** โ€” 7-table schema, set-based GTF
284
+ gene/transcript synthesis, recursive-CTE transitive closure,
285
+ per-seqid-banded R-tree spatial index built inline during ingest.
286
+ - **Smart routing** โ€” `region()` auto-picks R-tree vs B-tree;
287
+ `children()` auto-picks closure cache vs dynamic CTE based on
288
+ measured corpus depth.
289
+ - **Vectorized batched API** โ€” `children_batched`, `parents_batched`,
290
+ `region_batched` return `pyarrow.Table` / `pandas.DataFrame` /
291
+ `polars.DataFrame` directly out of DuckDB's buffer pool.
292
+ - **Drop-in legacy API** โ€” `FeatureDB`, `Feature`, `create_db`,
293
+ `DataIterator`, `GFFWriter`, `merge_criteria`, `interfeatures`,
294
+ `bed12`, `execute()` SQL escape hatch, `export_sqlite()`.
295
+ - **abi3 wheels** โ€” single binary per arch covers CPython 3.9โ€“3.13.
296
+
297
+ ---
298
+
299
+ ## ๐Ÿ“š Documentation
300
+
301
+ Full site (rendered with MkDocs Material) โ€” build it locally:
302
+
303
+ ```bash
304
+ pip install -e .[docs]
305
+ mkdocs serve # http://localhost:8000
306
+ ```
307
+
308
+ | Page | What's there |
309
+ | ------------------------------------------------------------------- | ------------------------------------------------------------------------- |
310
+ | [Usage Gallery](docs/usage_gallery.md) | Copy-pasteable snippets for every public API method |
311
+ | [Performance comparison](PERFORMANCE_COMPARISON.md) | Head-to-head numbers across every canonical human-genome annotation + per-corpus root-cause analysis |
312
+ | [Migration guide for `gffutils` users](MIGRATION.md) | Drop-in compat checklist + the one OLAP/OLTP gotcha you must understand |
313
+ | [Cookbooks](docs/cookbooks/) | GENCODE/Ensembl, RefSeq, MANE, ML workflows |
314
+ | [API reference](docs/api/) | Every public method, full signatures + docstrings |
315
+
316
+ ---
317
+
318
+ ## ๐Ÿงช Testing
319
+
320
+ ```bash
321
+ pip install -e .[test]
322
+ pytest # 523 passed, 7 skipped, 99.19% coverage
323
+ ```
324
+
325
+ CI runs the full matrix on Linux + macOS + Windows, both R-tree and
326
+ B-tree fallback paths, on Python 3.9 / 3.11 / 3.13.
327
+
328
+ ---
329
+
330
+ ## ๐Ÿค Contributing
331
+
332
+ GFFBase welcomes pull requests, bug reports, and feature suggestions.
333
+ Start with [`CONTRIBUTING.md`](CONTRIBUTING.md) for the full guide:
334
+
335
+ - Rust + Python development setup (`maturin develop --release`)
336
+ - Running the test suite + the 99 % coverage gate
337
+ - Branch naming, Conventional Commits, the PR checklist
338
+
339
+ The repo ships standard
340
+ [issue templates](.github/ISSUE_TEMPLATE/) and a
341
+ [PR template](.github/PULL_REQUEST_TEMPLATE.md) so new
342
+ contributions land with the context maintainers need to triage them
343
+ quickly.
344
+
345
+ ---
346
+
347
+ ## ๐Ÿชช License
348
+
349
+ Apache License 2.0. See [`LICENSE`](LICENSE).
350
+
351
+ ---
352
+
353
+ **Citation:** if GFFBase helps your research, please cite the project at
354
+ the [Releases page](https://github.com/Kuanhao-Chao/gffbase/releases).
355
+