opengwasdb 0.11.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 (182) hide show
  1. opengwasdb-0.11.1/.gitignore +27 -0
  2. opengwasdb-0.11.1/LICENSE +81 -0
  3. opengwasdb-0.11.1/PKG-INFO +105 -0
  4. opengwasdb-0.11.1/README.md +65 -0
  5. opengwasdb-0.11.1/opengwasdb/__init__.py +8 -0
  6. opengwasdb-0.11.1/opengwasdb/admission/__init__.py +47 -0
  7. opengwasdb-0.11.1/opengwasdb/admission/cells.py +83 -0
  8. opengwasdb-0.11.1/opengwasdb/admission/declared.py +86 -0
  9. opengwasdb-0.11.1/opengwasdb/admission/duplicates.py +36 -0
  10. opengwasdb-0.11.1/opengwasdb/admission/gate.py +175 -0
  11. opengwasdb-0.11.1/opengwasdb/admission/record.py +229 -0
  12. opengwasdb-0.11.1/opengwasdb/admission/rules.py +409 -0
  13. opengwasdb-0.11.1/opengwasdb/ancestry/__init__.py +52 -0
  14. opengwasdb-0.11.1/opengwasdb/ancestry/calibrate.py +234 -0
  15. opengwasdb-0.11.1/opengwasdb/ancestry/catalogue.py +171 -0
  16. opengwasdb-0.11.1/opengwasdb/ancestry/mixture.py +299 -0
  17. opengwasdb-0.11.1/opengwasdb/ancestry/pipeline.py +232 -0
  18. opengwasdb-0.11.1/opengwasdb/ancestry/reference.py +133 -0
  19. opengwasdb-0.11.1/opengwasdb/ancestry/routing.py +184 -0
  20. opengwasdb-0.11.1/opengwasdb/ancestry/subset.py +219 -0
  21. opengwasdb-0.11.1/opengwasdb/associations/__init__.py +47 -0
  22. opengwasdb-0.11.1/opengwasdb/associations/cells.py +185 -0
  23. opengwasdb-0.11.1/opengwasdb/associations/csr.py +383 -0
  24. opengwasdb-0.11.1/opengwasdb/associations/dense.py +317 -0
  25. opengwasdb-0.11.1/opengwasdb/associations/record.py +585 -0
  26. opengwasdb-0.11.1/opengwasdb/associations/subset.py +64 -0
  27. opengwasdb-0.11.1/opengwasdb/build/__init__.py +7 -0
  28. opengwasdb-0.11.1/opengwasdb/build/complete/__init__.py +2 -0
  29. opengwasdb-0.11.1/opengwasdb/build/eaf_orientation.py +1067 -0
  30. opengwasdb-0.11.1/opengwasdb/build/effect_consistency.py +187 -0
  31. opengwasdb-0.11.1/opengwasdb/build/hash_sample.py +62 -0
  32. opengwasdb-0.11.1/opengwasdb/build/info_score_filter.py +146 -0
  33. opengwasdb-0.11.1/opengwasdb/build/liftover.py +466 -0
  34. opengwasdb-0.11.1/opengwasdb/build/observed/__init__.py +96 -0
  35. opengwasdb-0.11.1/opengwasdb/build/ordered_pool.py +228 -0
  36. opengwasdb-0.11.1/opengwasdb/build/phenotype_sd.py +196 -0
  37. opengwasdb-0.11.1/opengwasdb/build/phenotype_sd_pipeline.py +367 -0
  38. opengwasdb-0.11.1/opengwasdb/build/resolve.py +1182 -0
  39. opengwasdb-0.11.1/opengwasdb/build/resolve_besd.py +204 -0
  40. opengwasdb-0.11.1/opengwasdb/build/resolve_manifest.py +1696 -0
  41. opengwasdb-0.11.1/opengwasdb/cli/__init__.py +2 -0
  42. opengwasdb-0.11.1/opengwasdb/cli/main.py +2303 -0
  43. opengwasdb-0.11.1/opengwasdb/completion/__init__.py +1 -0
  44. opengwasdb-0.11.1/opengwasdb/completion/ancestry_filter.py +133 -0
  45. opengwasdb-0.11.1/opengwasdb/completion/block.py +356 -0
  46. opengwasdb-0.11.1/opengwasdb/completion/checkpoint.py +224 -0
  47. opengwasdb-0.11.1/opengwasdb/completion/fill_shards.py +422 -0
  48. opengwasdb-0.11.1/opengwasdb/completion/impute.py +215 -0
  49. opengwasdb-0.11.1/opengwasdb/completion/ld_panel.py +902 -0
  50. opengwasdb-0.11.1/opengwasdb/completion/manifest.py +107 -0
  51. opengwasdb-0.11.1/opengwasdb/completion/parallel.py +58 -0
  52. opengwasdb-0.11.1/opengwasdb/completion/reference_eaf.py +78 -0
  53. opengwasdb-0.11.1/opengwasdb/completion/regions.py +241 -0
  54. opengwasdb-0.11.1/opengwasdb/completion/schema.py +76 -0
  55. opengwasdb-0.11.1/opengwasdb/encoding/__init__.py +192 -0
  56. opengwasdb-0.11.1/opengwasdb/encoding/association_codec.py +533 -0
  57. opengwasdb-0.11.1/opengwasdb/encoding/banding.py +73 -0
  58. opengwasdb-0.11.1/opengwasdb/encoding/codec.py +1608 -0
  59. opengwasdb-0.11.1/opengwasdb/encoding/measure.py +446 -0
  60. opengwasdb-0.11.1/opengwasdb/encoding/memory.py +187 -0
  61. opengwasdb-0.11.1/opengwasdb/encoding/plan.py +617 -0
  62. opengwasdb-0.11.1/opengwasdb/encoding/planes.py +1135 -0
  63. opengwasdb-0.11.1/opengwasdb/encoding/se.py +1701 -0
  64. opengwasdb-0.11.1/opengwasdb/encoding/timing.py +172 -0
  65. opengwasdb-0.11.1/opengwasdb/index/__init__.py +17 -0
  66. opengwasdb-0.11.1/opengwasdb/index/analyses.py +38 -0
  67. opengwasdb-0.11.1/opengwasdb/index/sqlite.py +48 -0
  68. opengwasdb-0.11.1/opengwasdb/layouts/__init__.py +2 -0
  69. opengwasdb-0.11.1/opengwasdb/layouts/build_manifest.py +359 -0
  70. opengwasdb-0.11.1/opengwasdb/layouts/dense/__init__.py +15 -0
  71. opengwasdb-0.11.1/opengwasdb/layouts/dense/build.py +595 -0
  72. opengwasdb-0.11.1/opengwasdb/layouts/dense/build_vcf.py +1870 -0
  73. opengwasdb-0.11.1/opengwasdb/layouts/dense/complete.py +1686 -0
  74. opengwasdb-0.11.1/opengwasdb/layouts/dense/constants.py +84 -0
  75. opengwasdb-0.11.1/opengwasdb/layouts/dense/indexed_subsets.py +4513 -0
  76. opengwasdb-0.11.1/opengwasdb/layouts/dense/rho.py +427 -0
  77. opengwasdb-0.11.1/opengwasdb/layouts/dense/top_hits.py +491 -0
  78. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/__init__.py +28 -0
  79. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/build.py +3645 -0
  80. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/checkpoint.py +434 -0
  81. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/complete.py +924 -0
  82. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/key_runs.py +307 -0
  83. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/key_table.py +515 -0
  84. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/layout.py +41 -0
  85. opengwasdb-0.11.1/opengwasdb/layouts/hybrid/unknown_keys.py +491 -0
  86. opengwasdb-0.11.1/opengwasdb/layouts/ragged/__init__.py +30 -0
  87. opengwasdb-0.11.1/opengwasdb/layouts/ragged/analyses.py +48 -0
  88. opengwasdb-0.11.1/opengwasdb/layouts/ragged/besd_eaf.py +153 -0
  89. opengwasdb-0.11.1/opengwasdb/layouts/ragged/besd_reader.py +317 -0
  90. opengwasdb-0.11.1/opengwasdb/layouts/ragged/build_besd.py +1522 -0
  91. opengwasdb-0.11.1/opengwasdb/layouts/ragged/build_ssf.py +1053 -0
  92. opengwasdb-0.11.1/opengwasdb/layouts/ragged/by_variant.py +1117 -0
  93. opengwasdb-0.11.1/opengwasdb/layouts/ragged/complete.py +1713 -0
  94. opengwasdb-0.11.1/opengwasdb/layouts/ragged/provenance.py +38 -0
  95. opengwasdb-0.11.1/opengwasdb/layouts/ragged/sample_size_table.py +213 -0
  96. opengwasdb-0.11.1/opengwasdb/layouts/ragged/ssf_lift.py +267 -0
  97. opengwasdb-0.11.1/opengwasdb/layouts/ragged/top_hits.py +191 -0
  98. opengwasdb-0.11.1/opengwasdb/layouts/ragged/trait_positions.py +119 -0
  99. opengwasdb-0.11.1/opengwasdb/layouts/ragged/zarr_csr.py +1676 -0
  100. opengwasdb-0.11.1/opengwasdb/layouts/release_manifest.py +60 -0
  101. opengwasdb-0.11.1/opengwasdb/model/__init__.py +78 -0
  102. opengwasdb-0.11.1/opengwasdb/model/analyses.py +755 -0
  103. opengwasdb-0.11.1/opengwasdb/model/enums.py +174 -0
  104. opengwasdb-0.11.1/opengwasdb/model/info_score_policy.py +169 -0
  105. opengwasdb-0.11.1/opengwasdb/model/maf_policy.py +96 -0
  106. opengwasdb-0.11.1/opengwasdb/model/manifest.py +171 -0
  107. opengwasdb-0.11.1/opengwasdb/model/manifest_columns.py +128 -0
  108. opengwasdb-0.11.1/opengwasdb/model/regions.py +201 -0
  109. opengwasdb-0.11.1/opengwasdb/overview.py +1477 -0
  110. opengwasdb-0.11.1/opengwasdb/query/__init__.py +7 -0
  111. opengwasdb-0.11.1/opengwasdb/query/facade.py +946 -0
  112. opengwasdb-0.11.1/opengwasdb/query/resolve.py +142 -0
  113. opengwasdb-0.11.1/opengwasdb/readers/__init__.py +84 -0
  114. opengwasdb-0.11.1/opengwasdb/readers/assembly.py +100 -0
  115. opengwasdb-0.11.1/opengwasdb/readers/association_tsv.py +289 -0
  116. opengwasdb-0.11.1/opengwasdb/readers/besd.py +444 -0
  117. opengwasdb-0.11.1/opengwasdb/readers/column_map.py +524 -0
  118. opengwasdb-0.11.1/opengwasdb/readers/column_map_reader.py +522 -0
  119. opengwasdb-0.11.1/opengwasdb/readers/column_maps/finngen-r13.toml +39 -0
  120. opengwasdb-0.11.1/opengwasdb/readers/column_maps/gwas-ssf.toml +44 -0
  121. opengwasdb-0.11.1/opengwasdb/readers/columnar.py +586 -0
  122. opengwasdb-0.11.1/opengwasdb/readers/effect_source.py +470 -0
  123. opengwasdb-0.11.1/opengwasdb/readers/fake.py +105 -0
  124. opengwasdb-0.11.1/opengwasdb/readers/finngen.py +537 -0
  125. opengwasdb-0.11.1/opengwasdb/readers/gwas_ssf.py +1211 -0
  126. opengwasdb-0.11.1/opengwasdb/readers/gwas_vcf.py +680 -0
  127. opengwasdb-0.11.1/opengwasdb/readers/interface.py +472 -0
  128. opengwasdb-0.11.1/opengwasdb/readers/orientation.py +66 -0
  129. opengwasdb-0.11.1/opengwasdb/readers/registry.py +292 -0
  130. opengwasdb-0.11.1/opengwasdb/readers/rows.py +493 -0
  131. opengwasdb-0.11.1/opengwasdb/readers/tabular.py +1454 -0
  132. opengwasdb-0.11.1/opengwasdb/reencode.py +466 -0
  133. opengwasdb-0.11.1/opengwasdb/repair.py +113 -0
  134. opengwasdb-0.11.1/opengwasdb/stats.py +128 -0
  135. opengwasdb-0.11.1/opengwasdb/store/__init__.py +65 -0
  136. opengwasdb-0.11.1/opengwasdb/store/arrays.py +2284 -0
  137. opengwasdb-0.11.1/opengwasdb/store/convert.py +1270 -0
  138. opengwasdb-0.11.1/opengwasdb/store/open.py +884 -0
  139. opengwasdb-0.11.1/opengwasdb/store/swap.py +77 -0
  140. opengwasdb-0.11.1/opengwasdb/top_hits.py +489 -0
  141. opengwasdb-0.11.1/opengwasdb/validation/__init__.py +6 -0
  142. opengwasdb-0.11.1/opengwasdb/validation/eaf_audit.py +168 -0
  143. opengwasdb-0.11.1/opengwasdb/validation/observed_view.py +765 -0
  144. opengwasdb-0.11.1/opengwasdb/validation/observed_view_hybrid.py +697 -0
  145. opengwasdb-0.11.1/opengwasdb/validation/observed_view_ragged.py +669 -0
  146. opengwasdb-0.11.1/opengwasdb/validation/rule.py +558 -0
  147. opengwasdb-0.11.1/opengwasdb/validation/rules/__init__.py +5 -0
  148. opengwasdb-0.11.1/opengwasdb/validation/rules/analyses.py +393 -0
  149. opengwasdb-0.11.1/opengwasdb/validation/rules/associations.py +336 -0
  150. opengwasdb-0.11.1/opengwasdb/validation/rules/by_variant.py +654 -0
  151. opengwasdb-0.11.1/opengwasdb/validation/rules/completion.py +380 -0
  152. opengwasdb-0.11.1/opengwasdb/validation/rules/csr.py +103 -0
  153. opengwasdb-0.11.1/opengwasdb/validation/rules/encoding.py +540 -0
  154. opengwasdb-0.11.1/opengwasdb/validation/rules/hybrid.py +118 -0
  155. opengwasdb-0.11.1/opengwasdb/validation/rules/layout.py +468 -0
  156. opengwasdb-0.11.1/opengwasdb/validation/rules/release.py +404 -0
  157. opengwasdb-0.11.1/opengwasdb/validation/rules/rho.py +118 -0
  158. opengwasdb-0.11.1/opengwasdb/validation/rules/sample_size.py +128 -0
  159. opengwasdb-0.11.1/opengwasdb/validation/rules/sequence.py +215 -0
  160. opengwasdb-0.11.1/opengwasdb/validation/rules/side_tables.py +385 -0
  161. opengwasdb-0.11.1/opengwasdb/validation/rules/subsets.py +147 -0
  162. opengwasdb-0.11.1/opengwasdb/validation/rules/top_hits.py +488 -0
  163. opengwasdb-0.11.1/opengwasdb/validation/rules/variants.py +507 -0
  164. opengwasdb-0.11.1/opengwasdb/validation/run.py +977 -0
  165. opengwasdb-0.11.1/opengwasdb/validation/scans.py +1080 -0
  166. opengwasdb-0.11.1/opengwasdb/validation/validate.py +724 -0
  167. opengwasdb-0.11.1/opengwasdb/variants/__init__.py +73 -0
  168. opengwasdb-0.11.1/opengwasdb/variants/axis.py +725 -0
  169. opengwasdb-0.11.1/opengwasdb/variants/normalise.py +503 -0
  170. opengwasdb-0.11.1/opengwasdb/variants/reference.py +863 -0
  171. opengwasdb-0.11.1/opengwasdb/variants/routing/__init__.py +65 -0
  172. opengwasdb-0.11.1/opengwasdb/variants/routing/extract.py +739 -0
  173. opengwasdb-0.11.1/opengwasdb/variants/routing/keys.py +210 -0
  174. opengwasdb-0.11.1/opengwasdb/variants/routing/lift.py +297 -0
  175. opengwasdb-0.11.1/opengwasdb/variants/routing/names.py +419 -0
  176. opengwasdb-0.11.1/opengwasdb/variants/routing/route.py +345 -0
  177. opengwasdb-0.11.1/opengwasdb/variants/routing/table.py +730 -0
  178. opengwasdb-0.11.1/opengwasdb/variants/routing/union.py +747 -0
  179. opengwasdb-0.11.1/opengwasdb/variants/rsid.py +149 -0
  180. opengwasdb-0.11.1/opengwasdb/variants/windows.py +46 -0
  181. opengwasdb-0.11.1/opengwasdb/version.py +41 -0
  182. opengwasdb-0.11.1/pyproject.toml +256 -0
@@ -0,0 +1,27 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .venv/
8
+ # Pixi-managed environments/cache: reproduced from pyproject.toml's
9
+ # [tool.pixi.*] tables + pixi.lock, never committed.
10
+ .pixi/
11
+ dist/
12
+ /build/
13
+ .DS_Store
14
+ docs/benchmark-output/*.opengwasdb/
15
+ docs/benchmark-output/*_combined_source.tsv.gz
16
+
17
+ # transient build logs (build.sh writes + rotates these)
18
+ data/**/build.log
19
+ data/**/build.log.*
20
+ # local agent state (not shared)
21
+ .pi/settings.json
22
+ .claude/settings.local.json
23
+ .claude/*.lock
24
+ .claude/worktrees/
25
+ quality/.running/
26
+ quality/.events.jsonl
27
+ logs/
@@ -0,0 +1,81 @@
1
+ # License
2
+
3
+ Copyright (c) 2026 Gibran Hemani
4
+
5
+ OpenGWASDB is licensed under the Sustainable Use License, version 1.0, below.
6
+ The licensor is Gibran Hemani. Third-party components it depends on are
7
+ licensed under their own licences.
8
+
9
+ ## Sustainable Use License
10
+
11
+ Version 1.0
12
+
13
+ ### Acceptance
14
+
15
+ By using the software, you agree to all of the terms and conditions below.
16
+
17
+ ### Copyright License
18
+
19
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
20
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
21
+ to the limitations below.
22
+
23
+ ### Limitations
24
+
25
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
26
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
27
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
28
+ the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
29
+
30
+ ### Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
33
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
34
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
35
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
36
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
37
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
38
+ license ends immediately for work on behalf of your company.
39
+
40
+ ### Notices
41
+
42
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
43
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
44
+ stating that you have modified the software.
45
+
46
+ ### No Other Rights
47
+
48
+ These terms do not imply any licenses other than those expressly granted in these terms.
49
+
50
+ ### Termination
51
+
52
+ If you use the software in violation of these terms, such use is not licensed, and your license will
53
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
54
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
55
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
56
+ terms will cause your license to terminate automatically and permanently.
57
+
58
+ ### No Liability
59
+
60
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
61
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
62
+ any kind of legal claim.
63
+
64
+ ### Definitions
65
+
66
+ The “licensor” is the entity offering these terms.
67
+
68
+ The “software” is the software the licensor makes available under these terms, including any portion of it.
69
+
70
+ “You” refers to the individual or entity agreeing to these terms.
71
+
72
+ “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
73
+ all organizations that have control over, are under the control of, or are under common control with that
74
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
75
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
76
+
77
+ “Your license” is the license granted to you for the software under these terms.
78
+
79
+ “Use” means anything you do with the software requiring your license.
80
+
81
+ “Trademark” means trademarks, service marks, and similar rights.
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.5
2
+ Name: opengwasdb
3
+ Version: 0.11.1
4
+ Summary: Standalone storage and query engine for OpenGWAS-scale summary statistic stores
5
+ Project-URL: Homepage, https://github.com/opengwas/opengwasdb
6
+ Project-URL: Documentation, https://blog.opengwas.io/opengwasdb/
7
+ Project-URL: Repository, https://github.com/opengwas/opengwasdb
8
+ Project-URL: Issues, https://github.com/opengwas/opengwasdb/issues
9
+ Project-URL: Changelog, https://github.com/opengwas/opengwasdb/releases
10
+ Author: OpenGWASDB contributors
11
+ License-Expression: LicenseRef-Sustainable-Use-License
12
+ License-File: LICENSE
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: numcodecs>=0.17
23
+ Requires-Dist: numpy<2.5,>=1.26
24
+ Requires-Dist: pandas>=2.0
25
+ Requires-Dist: pyliftover>=0.4
26
+ Requires-Dist: pysam>=0.22
27
+ Requires-Dist: scikit-learn>=1.3
28
+ Requires-Dist: scipy>=1.11
29
+ Requires-Dist: threadpoolctl>=3.0
30
+ Requires-Dist: typer>=0.12
31
+ Requires-Dist: zarr<4,>=3.4
32
+ Provides-Extra: dev
33
+ Requires-Dist: lizard>=1.17; extra == 'dev'
34
+ Requires-Dist: mypy>=1.10; extra == 'dev'
35
+ Requires-Dist: pytest-xdist>=3.6; extra == 'dev'
36
+ Requires-Dist: pytest>=8; extra == 'dev'
37
+ Requires-Dist: pyyaml>=6; extra == 'dev'
38
+ Requires-Dist: ruff>=0.6; extra == 'dev'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # opengwasdb
42
+
43
+ Standalone storage and query engine for OpenGWAS-scale summary statistic stores.
44
+
45
+ The store contract:
46
+
47
+ - self-contained store releases;
48
+ - embedded SQLite for metadata and lookup indexes;
49
+ - Zarr for compressed association arrays;
50
+ - layout-independent build and query APIs;
51
+ - optional reference completion using LD reference panels.
52
+
53
+ OpenGWASDB implements **Dense**, **Ragged**, and **Hybrid** layouts, with observed-only and reference completion; [docs/store-format-compatibility.md](./docs/store-format-compatibility.md) lists the `format_version`s each release reads and writes. Service and catalogue deployment are not part of this package.
54
+
55
+ For the broader OpenGWAS platform direction, see [docs/opengwas-roadmap.md](./docs/opengwas-roadmap.md).
56
+
57
+ ## Repository status
58
+
59
+ Pre-release, working toward a release candidate (see
60
+ [Roadmap 1](https://github.com/opengwas/opengwasdb/issues/88)). Dense, Ragged
61
+ and Hybrid layouts build, query, validate and reference-complete; the store
62
+ format is not yet stable and existing Store Releases will need rebuilding
63
+ before the candidate — see [CHANGELOG.md](./CHANGELOG.md) for what changed and
64
+ what is known to be missing.
65
+
66
+ The design baseline lives in:
67
+
68
+ - [CONTEXT.md](./CONTEXT.md) — domain glossary; the authority on vocabulary
69
+ - [docs/spec/store-format.md](./docs/spec/store-format.md) — the store contract
70
+ - [docs/adr/](./docs/adr/) — decisions and their consequences
71
+ - [CONTRIBUTING.md](./CONTRIBUTING.md) — how work moves through the repository
72
+
73
+ Work lands through a pull request to `main`; **every merge is a tagged
74
+ version**, noted by its `changelog.d/` fragments.
75
+
76
+ ## Getting started
77
+
78
+ Use [docs/getting-started.md](./docs/getting-started.md) for a first run:
79
+ install with Pixi, build an in-repository tiny Dense Store Release, validate it,
80
+ and run PheWAS, exact-lookup, and top-hit queries. The example needs no external
81
+ production data.
82
+
83
+ ## Development
84
+
85
+ All Python dependencies and native tooling (bcftools) are managed by
86
+ [Pixi](https://pixi.sh) from `pyproject.toml`'s `[tool.pixi.*]` tables. A
87
+ fresh checkout needs only Pixi installed:
88
+
89
+ ```bash
90
+ pixi run -e dev test # pytest
91
+ pixi run -e dev lint # ruff check .
92
+ pixi run -e dev typecheck # mypy opengwasdb
93
+ ```
94
+
95
+ For a one-off script or REPL, use `pixi run -e dev python <script>.py`
96
+ rather than invoking a bare interpreter.
97
+
98
+ `pip install -e ".[dev]"` also works, without `bcftools`. The version comes
99
+ from the `v*` tags; clone with them.
100
+
101
+ ## Licence
102
+
103
+ [Sustainable Use License](./LICENSE), version 1.0: use is limited to internal
104
+ business, non-commercial and personal purposes. It is not an OSI open-source
105
+ licence.
@@ -0,0 +1,65 @@
1
+ # opengwasdb
2
+
3
+ Standalone storage and query engine for OpenGWAS-scale summary statistic stores.
4
+
5
+ The store contract:
6
+
7
+ - self-contained store releases;
8
+ - embedded SQLite for metadata and lookup indexes;
9
+ - Zarr for compressed association arrays;
10
+ - layout-independent build and query APIs;
11
+ - optional reference completion using LD reference panels.
12
+
13
+ OpenGWASDB implements **Dense**, **Ragged**, and **Hybrid** layouts, with observed-only and reference completion; [docs/store-format-compatibility.md](./docs/store-format-compatibility.md) lists the `format_version`s each release reads and writes. Service and catalogue deployment are not part of this package.
14
+
15
+ For the broader OpenGWAS platform direction, see [docs/opengwas-roadmap.md](./docs/opengwas-roadmap.md).
16
+
17
+ ## Repository status
18
+
19
+ Pre-release, working toward a release candidate (see
20
+ [Roadmap 1](https://github.com/opengwas/opengwasdb/issues/88)). Dense, Ragged
21
+ and Hybrid layouts build, query, validate and reference-complete; the store
22
+ format is not yet stable and existing Store Releases will need rebuilding
23
+ before the candidate — see [CHANGELOG.md](./CHANGELOG.md) for what changed and
24
+ what is known to be missing.
25
+
26
+ The design baseline lives in:
27
+
28
+ - [CONTEXT.md](./CONTEXT.md) — domain glossary; the authority on vocabulary
29
+ - [docs/spec/store-format.md](./docs/spec/store-format.md) — the store contract
30
+ - [docs/adr/](./docs/adr/) — decisions and their consequences
31
+ - [CONTRIBUTING.md](./CONTRIBUTING.md) — how work moves through the repository
32
+
33
+ Work lands through a pull request to `main`; **every merge is a tagged
34
+ version**, noted by its `changelog.d/` fragments.
35
+
36
+ ## Getting started
37
+
38
+ Use [docs/getting-started.md](./docs/getting-started.md) for a first run:
39
+ install with Pixi, build an in-repository tiny Dense Store Release, validate it,
40
+ and run PheWAS, exact-lookup, and top-hit queries. The example needs no external
41
+ production data.
42
+
43
+ ## Development
44
+
45
+ All Python dependencies and native tooling (bcftools) are managed by
46
+ [Pixi](https://pixi.sh) from `pyproject.toml`'s `[tool.pixi.*]` tables. A
47
+ fresh checkout needs only Pixi installed:
48
+
49
+ ```bash
50
+ pixi run -e dev test # pytest
51
+ pixi run -e dev lint # ruff check .
52
+ pixi run -e dev typecheck # mypy opengwasdb
53
+ ```
54
+
55
+ For a one-off script or REPL, use `pixi run -e dev python <script>.py`
56
+ rather than invoking a bare interpreter.
57
+
58
+ `pip install -e ".[dev]"` also works, without `bcftools`. The version comes
59
+ from the `v*` tags; clone with them.
60
+
61
+ ## Licence
62
+
63
+ [Sustainable Use License](./LICENSE), version 1.0: use is limited to internal
64
+ business, non-commercial and personal purposes. It is not an OSI open-source
65
+ licence.
@@ -0,0 +1,8 @@
1
+ """OpenGWASDB storage and query engine."""
2
+
3
+ from opengwasdb.model.manifest import StoreManifest
4
+ from opengwasdb.store.open import OpenGWASDBStore, open_store
5
+ from opengwasdb.version import __version__
6
+
7
+ __all__ = ["OpenGWASDBStore", "StoreManifest", "__version__", "open_store"]
8
+
@@ -0,0 +1,47 @@
1
+ """Association Admission: which of an Analysis's source rows a Store admits.
2
+
3
+ One rule set for every builder and the resolver. A caller opens a `Gate` per
4
+ Analysis and hands it each batch of rows before they are matched to the
5
+ Variant Index; the gate returns the rows to keep and counts the rest by
6
+ `Reason`. A build's gates come from its `AdmissionRecord`, which writes what
7
+ each Analysis examined, admitted and dropped beside the Store Release; the
8
+ resolver's come from `counting_gate`, which only counts.
9
+ `opengwasdb.admission.rules` states the rules and their precedence, and
10
+ `require_admitted` checks Admission's guarantee on cells a writer is handed
11
+ from anywhere else.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from opengwasdb.admission.cells import (
17
+ NotAdmitted,
18
+ admissible,
19
+ require_admitted,
20
+ )
21
+ from opengwasdb.admission.gate import Gate, RoutedBatch, counting_gate
22
+ from opengwasdb.admission.record import (
23
+ ADMISSION_RULES,
24
+ AdmissionRecord,
25
+ AdmissionSummary,
26
+ RecordIncomplete,
27
+ admission_record_for,
28
+ )
29
+ from opengwasdb.admission.rules import AdmissionCounts, AnalysisRules, Reason, SourceRows
30
+
31
+ __all__ = [
32
+ "ADMISSION_RULES",
33
+ "AdmissionCounts",
34
+ "AdmissionRecord",
35
+ "AdmissionSummary",
36
+ "AnalysisRules",
37
+ "Gate",
38
+ "NotAdmitted",
39
+ "Reason",
40
+ "RecordIncomplete",
41
+ "RoutedBatch",
42
+ "SourceRows",
43
+ "admissible",
44
+ "admission_record_for",
45
+ "counting_gate",
46
+ "require_admitted",
47
+ ]
@@ -0,0 +1,83 @@
1
+ """What Admission guarantees of every cell a Store holds, and its checks.
2
+
3
+ A present cell has a finite z and a finite, positive SE; z is missing exactly
4
+ where SE is (spec §15, `opengwasdb.associations.record.states`); a frequency is
5
+ NaN or inside (0, 1); and a cell is flagged imputed only when it is present.
6
+ A builder's rows reach a Store through a `Gate`, which admits only such
7
+ cells; completion's candidates are checked by `admissible`, and a writer
8
+ handed cells from anywhere else checks them with `require_admitted`. A
9
+ completion reads its source Store's cells through the Association Reader, whose
10
+ presence rule refuses an invalid one with `InvalidAssociations` (ADR 0070).
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import numpy as np
16
+
17
+ from opengwasdb.associations.record import State, states
18
+
19
+ __all__ = ["NotAdmitted", "admissible", "require_admitted"]
20
+
21
+
22
+ class NotAdmitted(ValueError):
23
+ """A cell Admission would not admit reached a Store's writer."""
24
+
25
+
26
+ def admissible(z: np.ndarray, se: np.ndarray, *, narrowed_se: bool = False) -> np.ndarray:
27
+ """Which candidate cells may be stored as present: z finite, SE finite and positive.
28
+
29
+ ``narrowed_se`` admits an SE of ``+inf`` too: what a ``float16`` SE plane
30
+ holds for an admitted SE of 65,520 or more, read back or re-encoded, and
31
+ still an association (spec §15, issue #337).
32
+ """
33
+ with np.errstate(invalid="ignore"):
34
+ se_value = np.isfinite(se) | (narrowed_se & np.isposinf(se))
35
+ keep: np.ndarray = np.isfinite(z) & se_value & (se > 0)
36
+ return keep
37
+
38
+
39
+ def require_admitted(
40
+ z: np.ndarray,
41
+ se: np.ndarray,
42
+ eaf: np.ndarray | None = None,
43
+ imputed: np.ndarray | None = None,
44
+ *,
45
+ where: str,
46
+ narrowed_se: bool = False,
47
+ ) -> None:
48
+ """Refuse cells Admission would not have admitted, naming ``where`` and the first.
49
+
50
+ ``z`` and ``se`` are parallel arrays of any shape, NaN where missing;
51
+ ``eaf`` (NaN where absent) and ``imputed`` (the 0/1 mask) are optional and
52
+ parallel too. ``narrowed_se`` is `admissible`'s. Raises `NotAdmitted`
53
+ listing each broken rule's cell count.
54
+ """
55
+ z, se = np.asarray(z, dtype=np.float64), np.asarray(se, dtype=np.float64)
56
+ z_missing, se_missing = np.isnan(z), np.isnan(se)
57
+ state = states(z_missing, se_missing, None if imputed is None else np.asarray(imputed))
58
+ present = ~z_missing & ~se_missing
59
+ broken = {
60
+ "one of z and SE missing": state == State.PARTIAL,
61
+ "imputed flag on a missing cell": state == State.IMPUTED_MISSING,
62
+ "imputed flag neither 0 nor 1": state == State.FLAG_INVALID,
63
+ "present with an infinite z or an SE not finite and positive": present
64
+ & ~admissible(z, se, narrowed_se=narrowed_se),
65
+ }
66
+ if eaf is not None:
67
+ eaf = np.asarray(eaf, dtype=np.float64)
68
+ with np.errstate(invalid="ignore"):
69
+ broken["frequency outside (0, 1)"] = ~np.isnan(eaf) & ~((eaf > 0) & (eaf < 1))
70
+ _raise_if_broken(broken, where)
71
+
72
+
73
+ def _raise_if_broken(broken: dict[str, np.ndarray], where: str) -> None:
74
+ found = {rule: mask for rule, mask in broken.items() if mask.any()}
75
+ if not found:
76
+ return
77
+ first_rule, first_mask = next(iter(found.items()))
78
+ first = tuple(int(axis[0]) for axis in np.nonzero(first_mask))
79
+ counts = "; ".join(f"{rule}: {int(mask.sum()):,}" for rule, mask in found.items())
80
+ raise NotAdmitted(
81
+ f"{where}: cells Association Admission does not admit ({counts}); first "
82
+ f"{first_rule} at {first}"
83
+ )
@@ -0,0 +1,86 @@
1
+ """The filters each Analysis declared, read from its build manifest (stores #175, #176).
2
+
3
+ Every builder judges a row against the same declared INFO and MAF policies, so
4
+ they are parsed from the manifest one way: `declared_rules` reads each row's
5
+ policy columns, keyed by the row's Analysis id, and returns one
6
+ `AnalysisRules` per Analysis a builder parsed. A partial or contradictory
7
+ declaration is a manifest error naming its Analysis, never a filter silently
8
+ not applied.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import csv
14
+ from collections.abc import Mapping
15
+ from pathlib import Path
16
+
17
+ from opengwasdb.admission.rules import AnalysisRules
18
+ from opengwasdb.model.info_score_policy import parse_info_score_policy
19
+ from opengwasdb.model.maf_policy import parse_maf_policy
20
+ from opengwasdb.model.manifest_columns import manifest_column
21
+
22
+ __all__ = ["declared_rules"]
23
+
24
+
25
+ def declared_rules(
26
+ manifest_path: str | Path, capabilities: Mapping[str, str | None]
27
+ ) -> dict[str, AnalysisRules]:
28
+ """Each Analysis's declared rules, by Analysis id.
29
+
30
+ ``capabilities`` names the Analyses the builder parsed from the same
31
+ manifest, each with its resolved reader capability (the row's, or the
32
+ build's default), which decides whether a declared score can be read: a
33
+ numeric INFO threshold needs a GWAS-SSF source. Rows are matched by their
34
+ `analysis_id` (or legacy `trait_id`) column, so a builder's own row order
35
+ does not matter, and a manifest whose Analyses differ from the builder's
36
+ is refused.
37
+ """
38
+ with open(manifest_path, newline="", encoding="utf-8") as fh:
39
+ reader = csv.DictReader(fh, delimiter="\t")
40
+ id_column = manifest_column(reader.fieldnames or [], "analysis_id")
41
+ raw_rows = list(reader)
42
+ _refuse_repeated(manifest_path, id_column, raw_rows)
43
+ found = {raw.get(id_column or "", "") for raw in raw_rows}
44
+ if id_column is None or found != set(capabilities) or len(raw_rows) != len(capabilities):
45
+ raise ValueError(
46
+ f"manifest {manifest_path} changed while it was read: its Analyses are not "
47
+ f"the {len(capabilities)} the build parsed"
48
+ )
49
+ return {
50
+ raw[id_column]: _rules(manifest_path, raw[id_column], raw, capabilities[raw[id_column]])
51
+ for raw in raw_rows
52
+ }
53
+
54
+
55
+ def _refuse_repeated(
56
+ manifest_path: str | Path, id_column: str | None, raw_rows: list[dict[str, str]]
57
+ ) -> None:
58
+ """Refuse an Analysis a manifest names in more than one row, naming it and the rows."""
59
+ rows: dict[str, list[int]] = {}
60
+ for number, raw in enumerate(raw_rows, start=2): # the header is line 1
61
+ rows.setdefault(raw.get(id_column or "", ""), []).append(number)
62
+ for analysis_id, numbers in rows.items():
63
+ if len(numbers) > 1:
64
+ named = ", ".join(map(str, numbers[:-1])) + f" and {numbers[-1]}"
65
+ raise ValueError(
66
+ f"manifest {manifest_path}: analysis {analysis_id!r} is named by rows {named}; "
67
+ "one row each"
68
+ )
69
+
70
+
71
+ def _rules(
72
+ manifest_path: str | Path, analysis_id: str, raw: Mapping[str, str], capability: str | None
73
+ ) -> AnalysisRules:
74
+ try:
75
+ info = parse_info_score_policy(raw, reader_capability=capability)
76
+ except ValueError as exc:
77
+ raise ValueError(
78
+ f"manifest {manifest_path}: analysis {analysis_id!r} has invalid INFO policy: {exc}"
79
+ ) from exc
80
+ try:
81
+ maf = parse_maf_policy(raw)
82
+ except ValueError as exc:
83
+ raise ValueError(
84
+ f"manifest {manifest_path}: analysis {analysis_id!r} has invalid MAF policy: {exc}"
85
+ ) from exc
86
+ return AnalysisRules(analysis_id, info=info, maf=maf)
@@ -0,0 +1,36 @@
1
+ """How a gate records what Variant Routing resolved among an axis's duplicates.
2
+
3
+ Routing places each (variant, Analysis) once (`collapse_duplicates`): rows that
4
+ agree collapse to the first, and rows that disagree are all dropped. Both leave
5
+ the gate's admitted rows; the dropped ones are logged by the ALID of the
6
+ variant they reached.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from collections.abc import Sequence
12
+ from typing import Protocol
13
+
14
+ import numpy as np
15
+
16
+ from opengwasdb.admission.gate import Gate
17
+
18
+ __all__ = ["record_duplicates"]
19
+
20
+
21
+ class PlacedDuplicates(Protocol):
22
+ """What routing reports of one axis's duplicates: `Placed`'s fields."""
23
+
24
+ @property
25
+ def dropped(self) -> np.ndarray: ...
26
+
27
+ @property
28
+ def collapsed(self) -> int: ...
29
+
30
+
31
+ def record_duplicates(gate: Gate, placed: PlacedDuplicates, alids: Sequence[str]) -> None:
32
+ """Count one axis's collapsed rows and count and log its dropped ones.
33
+
34
+ ``alids`` is that axis, so ``placed.dropped``'s indices name variants.
35
+ """
36
+ gate.duplicates([alids[i] for i in placed.dropped.tolist()], placed.collapsed)