osteosarc 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 (72) hide show
  1. osteosarc-0.1.0/LICENSE +201 -0
  2. osteosarc-0.1.0/MANIFEST.in +5 -0
  3. osteosarc-0.1.0/PKG-INFO +343 -0
  4. osteosarc-0.1.0/README.md +307 -0
  5. osteosarc-0.1.0/docs/api.md +104 -0
  6. osteosarc-0.1.0/docs/consumers.md +159 -0
  7. osteosarc-0.1.0/docs/curation.md +236 -0
  8. osteosarc-0.1.0/docs/design.md +62 -0
  9. osteosarc-0.1.0/docs/explore.md +131 -0
  10. osteosarc-0.1.0/docs/index.md +89 -0
  11. osteosarc-0.1.0/docs/migration.md +112 -0
  12. osteosarc-0.1.0/docs/reads.md +103 -0
  13. osteosarc-0.1.0/docs/timeline.md +154 -0
  14. osteosarc-0.1.0/docs/tour.md +177 -0
  15. osteosarc-0.1.0/docs/validation.md +161 -0
  16. osteosarc-0.1.0/docs/variants.md +87 -0
  17. osteosarc-0.1.0/mkdocs.yml +31 -0
  18. osteosarc-0.1.0/osteosarc/__init__.py +34 -0
  19. osteosarc-0.1.0/osteosarc/__main__.py +3 -0
  20. osteosarc-0.1.0/osteosarc/cache.py +292 -0
  21. osteosarc-0.1.0/osteosarc/catalog.py +235 -0
  22. osteosarc-0.1.0/osteosarc/cli.py +180 -0
  23. osteosarc-0.1.0/osteosarc/curation.py +669 -0
  24. osteosarc-0.1.0/osteosarc/dataset.py +587 -0
  25. osteosarc-0.1.0/osteosarc/discovery.py +44 -0
  26. osteosarc-0.1.0/osteosarc/errors.py +21 -0
  27. osteosarc-0.1.0/osteosarc/explore.py +286 -0
  28. osteosarc-0.1.0/osteosarc/models.py +236 -0
  29. osteosarc-0.1.0/osteosarc/parsing.py +200 -0
  30. osteosarc-0.1.0/osteosarc/reads.py +402 -0
  31. osteosarc-0.1.0/osteosarc/timeline.py +369 -0
  32. osteosarc-0.1.0/osteosarc/urls.py +5 -0
  33. osteosarc-0.1.0/osteosarc.egg-info/PKG-INFO +343 -0
  34. osteosarc-0.1.0/osteosarc.egg-info/SOURCES.txt +70 -0
  35. osteosarc-0.1.0/osteosarc.egg-info/dependency_links.txt +1 -0
  36. osteosarc-0.1.0/osteosarc.egg-info/entry_points.txt +2 -0
  37. osteosarc-0.1.0/osteosarc.egg-info/requires.txt +13 -0
  38. osteosarc-0.1.0/osteosarc.egg-info/top_level.txt +1 -0
  39. osteosarc-0.1.0/pyproject.toml +58 -0
  40. osteosarc-0.1.0/scripts/build_test_fixtures.py +122 -0
  41. osteosarc-0.1.0/scripts/check_docs.py +156 -0
  42. osteosarc-0.1.0/setup.cfg +4 -0
  43. osteosarc-0.1.0/tests/conftest.py +59 -0
  44. osteosarc-0.1.0/tests/data/bam-metadata.tsv +4 -0
  45. osteosarc-0.1.0/tests/data/bams.json +29 -0
  46. osteosarc-0.1.0/tests/data/bucket_listing.json +37 -0
  47. osteosarc-0.1.0/tests/data/cytometry.tsv +62 -0
  48. osteosarc-0.1.0/tests/data/data.html +1 -0
  49. osteosarc-0.1.0/tests/data/dicom-studies.json +50 -0
  50. osteosarc-0.1.0/tests/data/events.json +383 -0
  51. osteosarc-0.1.0/tests/data/fastqs-consolidated.tsv +22 -0
  52. osteosarc-0.1.0/tests/data/flow-manifest.json +89 -0
  53. osteosarc-0.1.0/tests/data/lab_results.tsv +89 -0
  54. osteosarc-0.1.0/tests/data/mrd.json +67 -0
  55. osteosarc-0.1.0/tests/data/pathology-slides.json +53 -0
  56. osteosarc-0.1.0/tests/data/provenance.json +86 -0
  57. osteosarc-0.1.0/tests/data/samples-consolidated.tsv +9 -0
  58. osteosarc-0.1.0/tests/data/samples.json +28 -0
  59. osteosarc-0.1.0/tests/data/source-variants.json +699 -0
  60. osteosarc-0.1.0/tests/data/timeline.csv +45 -0
  61. osteosarc-0.1.0/tests/data/vaccine_overlap.json +110 -0
  62. osteosarc-0.1.0/tests/data/vafs-columns.tsv +27 -0
  63. osteosarc-0.1.0/tests/data/vafs.tsv +115 -0
  64. osteosarc-0.1.0/tests/data/variants.html +5 -0
  65. osteosarc-0.1.0/tests/test_cache.py +153 -0
  66. osteosarc-0.1.0/tests/test_consumer_usage.py +156 -0
  67. osteosarc-0.1.0/tests/test_curation.py +207 -0
  68. osteosarc-0.1.0/tests/test_dataset.py +193 -0
  69. osteosarc-0.1.0/tests/test_discovery.py +43 -0
  70. osteosarc-0.1.0/tests/test_parsing.py +79 -0
  71. osteosarc-0.1.0/tests/test_reads.py +186 -0
  72. osteosarc-0.1.0/tests/test_timeline.py +201 -0
@@ -0,0 +1,201 @@
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 reasonable and customary use in describing the
141
+ origin of the Work and 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 choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include mkdocs.yml
3
+ recursive-include docs *.md
4
+ recursive-include tests *.py *.json *.tsv *.csv *.html
5
+ recursive-include scripts *.py
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: osteosarc
3
+ Version: 0.1.0
4
+ Summary: Reproducible access to the public osteosarc.com dataset
5
+ Author-email: Alex Rubinsteyn <alex.rubinsteyn@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Documentation, https://iskandr.github.io/osteosarc/
8
+ Project-URL: Source, https://github.com/iskandr/osteosarc
9
+ Project-URL: Issues, https://github.com/iskandr/osteosarc/issues
10
+ Project-URL: Dataset, https://osteosarc.com/data/
11
+ Keywords: osteosarcoma,genomics,neoantigen,bioinformatics,openvax
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: beautifulsoup4>=4.12
26
+ Provides-Extra: reads
27
+ Requires-Dist: pysam>=0.22; extra == "reads"
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=8; extra == "test"
30
+ Requires-Dist: pysam>=0.22; extra == "test"
31
+ Requires-Dist: ruff>=0.9; extra == "test"
32
+ Requires-Dist: build>=1; extra == "test"
33
+ Provides-Extra: docs
34
+ Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # osteosarc
38
+
39
+ A shared Python API for the public [osteosarc.com](https://osteosarc.com/data/)
40
+ dataset: discover files, cache verified downloads, parse source tables, select
41
+ variants and vaccines, and extract indexed sequencing reads.
42
+
43
+ The initial implementation consolidates the acquisition patterns found in
44
+ Varcode, Isovar, Topiary, and Vaxrank. Those repositories have not yet been
45
+ migrated. See the [comparison and migration guide](https://iskandr.github.io/osteosarc/migration/).
46
+
47
+ [Documentation and short examples](https://iskandr.github.io/osteosarc/) ·
48
+ [Consumer migration recipes](https://iskandr.github.io/osteosarc/consumers/)
49
+
50
+ ## Install
51
+
52
+ Python 3.10+, Linux or macOS, and `curl` are required. Indexed read extraction
53
+ also requires `samtools` on PATH and the `reads` extra.
54
+
55
+ ```sh
56
+ python -m pip install 'osteosarc[reads]'
57
+ ```
58
+
59
+ For development, clone the repository and use `python -m pip install -e '.[test]'`.
60
+
61
+ ## One dataset, one cache
62
+
63
+ ```python
64
+ from osteosarc import Cache, Dataset
65
+
66
+ cache = Cache() # the shared OpenVax cache (see below)
67
+ data = Dataset.sync("2026-09-18", cache=cache) # explicit metadata download
68
+
69
+ # Later: verifies the saved snapshot and opens it without network access.
70
+ data = Dataset.open("2026-09-18", cache=cache)
71
+ ```
72
+
73
+ `sync` acquires about 57 MB of metadata, including the full dated bucket index
74
+ and the timeline sources.
75
+ It does not download BAMs, FASTQs, or other large data files. Importing the
76
+ package also does no downloading.
77
+
78
+ Files are stored in the **shared OpenVax cache**, the same layout vaxrank's
79
+ downloader uses, so identical bytes are stored once across OpenVax tools:
80
+ `<root>/objects/sha256/<sha256><original suffixes>` (for example
81
+ `…9c2e.genes.results`). osteosarc keeps its receipts, snapshots, bindings and
82
+ extracted reads under `<root>/osteosarc/`. The root is `OPENVAX_DATA_CACHE`,
83
+ otherwise the platform cache directory for `openvax` (`~/Library/Caches/openvax`
84
+ on macOS, `$XDG_CACHE_HOME/openvax` or `~/.cache/openvax` on Linux).
85
+ `OSTEOSARC_CACHE` or `Cache(root)` selects an isolated cache instead.
86
+
87
+ Snapshots pin source URLs and SHA256 receipts. Downloads use atomic publication,
88
+ per-URL locks, bounded retries, and checksum verification on reuse. Interrupted
89
+ downloads restart; byte-range resume of whole objects is not implemented.
90
+ `Dataset.download` binds its first acquired receipt to that snapshot, so
91
+ refreshing a URL elsewhere cannot change previously acquired data. Use a new
92
+ name with `Dataset.sync(..., refresh=True)` to acquire fresh metadata. Existing
93
+ snapshot names cannot be overwritten. `Cache.fetch(url, refresh=True)` can
94
+ refresh standalone downloads while keeping old content available.
95
+
96
+ ## Find samples and sequencing products
97
+
98
+ ```python
99
+ data = Dataset.open("2026-09-18", offline=False) # permit explicit acquisition
100
+
101
+ rna = data.assets.select(kind="alignment", assay="rna-seq", timepoint="T2")
102
+ ont = data.assets.select(kind="alignment", platform="ont")
103
+ vcfs = data.assets.select(kind="variants", format="vcf")
104
+ pvac = data.assets.select(prefix="neoantigen_prediction/pvactools/", format="tsv")
105
+ hla = data.assets.select(contains="hla", format="tsv")
106
+ raw_reads = data.assets.select(kind="reads", timepoint="T1")
107
+
108
+ sample_claims = data.samples # table with source and asset IDs
109
+ timepoint_claims = data.timepoints # published date precision is preserved
110
+
111
+ for asset in rna:
112
+ print(asset.id, asset.key, asset.size, asset.conflicts)
113
+ ```
114
+
115
+ An **asset is a processing product**, not an independent biological replicate.
116
+ An ID hashes the complete URL, so identical filenames in different directories
117
+ remain distinct. Sample claims come from the BAM viewer, consolidated public
118
+ metadata, VAF export, and data-page tables. Conflicting or absent values do not
119
+ match a metadata filter by default. Inspect `asset.claims`, `asset.conflicts`,
120
+ or `asset.values("timepoint")`; use `include_conflicts=True` to match any claim.
121
+ The catalog-wide viewer assembly label is never used to authorize read queries.
122
+
123
+ Assays are `rna-seq`, `scrna-seq`, `cite-seq`, `wgs`, and `wes`; known platforms
124
+ are `ont`, `pacbio`, and `illumina`. Platform is left unknown when it is not
125
+ explicit in the source. For paths with no published mapping, timepoint and a
126
+ few recognizable library IDs are retained as **inferences**, accessible with
127
+ `include_inferred=True`. Pooled blood libraries remain library-level records.
128
+
129
+ Every bucket object remains discoverable, including unclassified files.
130
+ The website listing has its own generation date and is not guaranteed current.
131
+ To discover newer files explicitly:
132
+
133
+ ```python
134
+ from osteosarc import list_bucket
135
+
136
+ listing = list_bucket(cache, "ONT/", refresh=True)
137
+ # listing["files"]: complete key/size/mtime rows; listing["receipts"]: every page
138
+ ```
139
+
140
+ Live listings are returned separately; they do not silently mutate a snapshot.
141
+ Missing or repeated continuation tokens and incomplete pagination raise errors.
142
+
143
+ ## Variant sets, annotations, and vaccines
144
+
145
+ ```python
146
+ site = data.variants() # every site entry, including unresolved
147
+ all_exported = data.variants("all") # also includes count-export entries
148
+ vaccine_targets = data.variants("vaccine") # site-reported vaccine count > 0
149
+ mrna = data.variants(vaccine="mRNA") # vaccine-overlap JSON membership
150
+ ready = site.select(status="ready")
151
+ dynein = site.select(gene="DYNC1H1") # may contain multiple alleles
152
+ detected = data.variants(pipeline="oncoanalyser")
153
+
154
+ print(data.vaccine_names, data.pipeline_names)
155
+ annotations = data.annotations # original variant annotation records
156
+ peptides = data.vaccine_peptides("mRNA")
157
+ elispot = data.vaccines # original tested/status/response fields
158
+
159
+ # A different source's membership assertion, explicitly requested:
160
+ source_membership = data.variants(vaccine="JLF V3", vaccine_source="source_variants")
161
+ ```
162
+
163
+ The variant index, vaccine-overlap JSON, and source variant JSON can disagree.
164
+ `Variant.vaccines` contains overlap-JSON membership joined only at an unambiguous
165
+ gene/locus; `annotations["source_vaccines"]` preserves source-JSON flags.
166
+ Disagreements and ambiguous joins remain in annotations. Counts from the site
167
+ table, peptide inclusion, pipeline detection, and ELISPOT measurements are kept
168
+ separately. A blank or untested measurement is not converted to a negative one.
169
+
170
+ Variants retain the published assembly and original VCF-style anchored allele.
171
+ `ready` means a unique literal allele with internally consistent coordinates;
172
+ it does **not** mean independently validated, somatic, normalized, or clinically
173
+ confirmed. Incomplete entries have a status such as `missing_literal_allele`,
174
+ `non_literal_allele`, or `ambiguous_literal_allele`. No allele is fabricated from
175
+ a gene symbol or protein label, and no coordinates are silently lifted over.
176
+
177
+ ## Timelines, specimens, and the terminal explorer
178
+
179
+ ```python
180
+ print(data.timeline.render(since="2024-05", until="2024-09", width=100))
181
+ print(data.timeline.around("2025-01-28", days=5).listing())
182
+ t2 = next(r for r in data.specimens if r["sample_id"] == "T2_tumor")
183
+ print(t2["date"], t2["site"], len(t2["assets"]), t2["corrections"])
184
+ mrd = data.measurements.select(source="mrd")
185
+ ```
186
+
187
+ The timeline brings together every dated public source: treatments and doses,
188
+ procedures, imaging (events and DICOM studies), pathology, omics, time points,
189
+ specimens, MRD, flow-cytometry draws, and lab and cytometry dates. Run
190
+ `osteosarc explore baseline` to browse it interactively, or
191
+ `osteosarc timeline baseline --since 2024-05` for a chart. See
192
+ [timelines](https://iskandr.github.io/osteosarc/timeline/) and the [guided tour](https://iskandr.github.io/osteosarc/tour/).
193
+
194
+ ## Corrections are central, optional, and drift-aware
195
+
196
+ All hand-written interpretation of the sources lives in `osteosarc/curation.py`.
197
+ Verified corrections are applied by default, for example the GRCh37 Tempus
198
+ counts, five relocated Tempus alleles, MAP2's observed allele, stale viewer
199
+ labels, and specimen dates and sites. Each touched object names its
200
+ corrections, and `Dataset.open(name, corrections=False)` gives the published
201
+ sources unchanged. Every load re-checks each correction against the sources, so
202
+ an upstream change makes it `stale` and unapplied rather than silently wrong.
203
+
204
+ ```python
205
+ for row in data.corrections:
206
+ print(row["status"], row["id"])
207
+ print(list(data.unrecognized)) # labels outside the vocabulary
208
+ ```
209
+
210
+ `osteosarc curation baseline --strict` exits nonzero on drift. See
211
+ [corrections and drift](https://iskandr.github.io/osteosarc/curation/).
212
+
213
+ ## Download and parse
214
+
215
+ ```python
216
+ counts = data.table("vafs")
217
+ counts_for_gene = counts.select(gene="SMC5") # raw values, including "0" and "NA"
218
+ dna_fusions = data.table("dna_fusions")
219
+ rna_fusions = data.table("rna_fusions")
220
+ snvs = data.table("snv_top")
221
+
222
+ report = pvac[0]
223
+ path = data.download(report) # explicit full-object download
224
+ table = data.parse(report) # same cache; original column names/strings
225
+ frame = table.to_dataframe() # optional pandas, no automatic numeric coercion
226
+
227
+ with data.open_variants(vcfs[0]) as calls: # optional pysam
228
+ for call in calls:
229
+ print(call.contig, call.pos, call.ref, call.alts)
230
+ ```
231
+
232
+ Built-in parsers cover TSV, CSV, JSON, and FASTA. `open_variants` preserves
233
+ VCF/BCF headers, INFO/FORMAT fields, sample genotypes, multiallelic records, and
234
+ symbolic alleles through pysam. Other objects (GTFs, matrices, RDS, imaging,
235
+ etc.) can be downloaded for their format-specific tools. Parsing a large text
236
+ table or FASTA currently materializes it in memory; use its downloaded path
237
+ with a streaming reader for very large files.
238
+
239
+ ## Indexed read extraction
240
+
241
+ ```python
242
+ from osteosarc import ReadFilter, Region
243
+
244
+ # Explicit source product; prefix/substring selectors can return several BAMs.
245
+ source = data.asset(
246
+ "rna-seq/reprocessed/BG003082/BG003082.Aligned.sortedByCoord.out.md.bam"
247
+ )
248
+ variant = data.variants()["DYNC1H1-chr14-101980529"]
249
+ subset = data.extract_reads(source, [variant.region(padding=100)])
250
+
251
+ # Region coordinates in Python are always zero-based and half-open.
252
+ region = Region("chr14", 101980528, 101980530, "GRCh38")
253
+ filtered = data.extract_reads(
254
+ source, [region], filters=ReadFilter(min_mapq=20, exclude_flags=0x100 | 0x400)
255
+ )
256
+ with subset.open() as bam:
257
+ for read in bam.fetch("chr14", 101980528, 101980530):
258
+ print(read.query_name, read.cigarstring)
259
+ ```
260
+
261
+ The extractor inspects reference lengths before querying, resolves contig
262
+ aliases, and refuses assembly conflicts, out-of-bounds intervals, ambiguous
263
+ contigs, and missing indexes. GRCh37 mitochondrial queries additionally require
264
+ the exact `reference_length` because hg19 and hs37d5 differ there. CRAM requires
265
+ a local indexed reference FASTA. Sparse/custom reference headers that cannot
266
+ establish the assembly are rejected.
267
+
268
+ SAMtools reads the indexed union of all intervals. Overlapping query intervals
269
+ do not cause repeated emission; genuine repeated source records are preserved.
270
+ Defaults retain secondary, supplementary, duplicate-marked, and low-MAPQ reads,
271
+ including original qualities, barcodes, UMIs, and other tags. Optional filters
272
+ are recorded in the request. `ReadFilter(barcodes=("...",))` selects the `CB`
273
+ tag (customizable via `barcode_tag`). `fetch_pairs=True` additionally retrieves
274
+ paired mates, but is not recovery of every supplementary record for a template.
275
+
276
+ The result contains an indexed BAM, source header, BED intervals, checksum
277
+ receipt, source/index identities, tool versions, and record count. It is cached
278
+ by the complete request. Remote identity is checked before and after new
279
+ extractions; cached results are verified offline without contacting the source.
280
+ No full-alignment scan is used as a fallback.
281
+
282
+ Local BAMs use the same implementation:
283
+
284
+ ```python
285
+ from osteosarc import extract_reads, subset_templates
286
+
287
+ local = str(subset.path) # any local indexed BAM; here, the subset from above
288
+ regional = extract_reads(local, [region], cache=cache)
289
+ fixture = subset_templates(regional, count=48, seed="regression-v1", cache=cache)
290
+ ```
291
+
292
+ Template sampling is a separate operation, keyed by `(read group, query name)`.
293
+ It retains all available regional records for selected templates and marks the
294
+ receipt as a sampled fixture unsuitable for estimating VAF.
295
+
296
+ ## Downstream libraries and CLI
297
+
298
+ ```python
299
+ # Optional varcode / pyensembl adapter; the caller provides its reference.
300
+ from pyensembl import EnsemblRelease
301
+ variants = ready.to_varcode(genome=EnsemblRelease(95))
302
+ # Pass variants and subset.path to Isovar, then its products to Topiary/Vaxrank.
303
+ ```
304
+
305
+ Osteosarc does not choose an Ensembl release, install a genome, calculate effects,
306
+ assemble RNA, score epitopes, infer somatic truth, or design a vaccine.
307
+
308
+ ```sh
309
+ osteosarc --cache .cache/osteosarc sync baseline
310
+ osteosarc --cache .cache/osteosarc assets baseline --assay rna-seq --timepoint T2
311
+ osteosarc --cache .cache/osteosarc variants baseline --set vaccine --status ready
312
+ osteosarc --cache .cache/osteosarc variants baseline --vaccine 'JLF V3'
313
+ osteosarc --cache .cache/osteosarc table baseline dna_fusions
314
+ osteosarc --cache .cache/osteosarc reads baseline 'rna-seq/reprocessed/BG003082/BG003082.Aligned.sortedByCoord.out.md.bam' chr14:101980529-101980530 --assembly GRCh38
315
+ osteosarc --cache .cache/osteosarc discover 'neoantigen_prediction/pvactools/'
316
+ osteosarc --cache .cache/osteosarc timeline baseline --since 2024-05 --until 2024-09
317
+ osteosarc --cache .cache/osteosarc specimens baseline T1_tumor
318
+ osteosarc --cache .cache/osteosarc curation baseline --strict
319
+ osteosarc --cache .cache/osteosarc --no-corrections variants baseline --gene MAP2
320
+ ```
321
+
322
+ CLI regions are **one-based inclusive**, matching SAMtools. Add the global
323
+ `--offline` flag to prohibit acquisition. `sync --source-revision <commit>` pins
324
+ every GitLab source-repository resource (variant JSON, BAM metadata, and the
325
+ timeline and specimen sources) to a full commit; site-served files are not
326
+ versioned by the site.
327
+
328
+ ## Development and provenance
329
+
330
+ ```sh
331
+ python -m pip install -e '.[test]'
332
+ ruff check osteosarc tests scripts
333
+ python -m pytest -q
334
+ python -m build --no-isolation
335
+ ```
336
+
337
+ Tests are offline and use small public metadata excerpts plus synthetic indexed
338
+ BAMs. See [validation](https://iskandr.github.io/osteosarc/validation/) for the bounded live check and
339
+ [API contracts](https://iskandr.github.io/osteosarc/design/) for the design rationale.
340
+
341
+ Code is Apache-2.0. The public dataset is separately listed as CC0-1.0 in the
342
+ [AWS Open Data Registry](https://registry.opendata.aws/sid-osteosarc/). Cite the
343
+ dataset and the access date when using its data.