gain-core 2026.10.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. gain_core-2026.10.2/.gitignore +113 -0
  2. gain_core-2026.10.2/PKG-INFO +51 -0
  3. gain_core-2026.10.2/README.md +6 -0
  4. gain_core-2026.10.2/gain/__init__.py +14 -0
  5. gain_core-2026.10.2/gain/_version.py +24 -0
  6. gain_core-2026.10.2/gain/annotation/TODO_annotation_documentation.md +38 -0
  7. gain_core-2026.10.2/gain/annotation/__init__.py +0 -0
  8. gain_core-2026.10.2/gain/annotation/allele_score_annotator.py +384 -0
  9. gain_core-2026.10.2/gain/annotation/allele_scores.md +167 -0
  10. gain_core-2026.10.2/gain/annotation/annotatable.py +373 -0
  11. gain_core-2026.10.2/gain/annotation/annotate_doc.py +66 -0
  12. gain_core-2026.10.2/gain/annotation/annotate_tabular.py +948 -0
  13. gain_core-2026.10.2/gain/annotation/annotate_utils.py +385 -0
  14. gain_core-2026.10.2/gain/annotation/annotate_vcf.py +794 -0
  15. gain_core-2026.10.2/gain/annotation/annotation_config.py +1138 -0
  16. gain_core-2026.10.2/gain/annotation/annotation_factory.py +324 -0
  17. gain_core-2026.10.2/gain/annotation/annotation_genomic_context_cli.py +157 -0
  18. gain_core-2026.10.2/gain/annotation/annotation_pipeline.py +878 -0
  19. gain_core-2026.10.2/gain/annotation/annotator_base.py +499 -0
  20. gain_core-2026.10.2/gain/annotation/chrom_mapping_annotator.py +79 -0
  21. gain_core-2026.10.2/gain/annotation/debug_annotator.py +37 -0
  22. gain_core-2026.10.2/gain/annotation/docker_annotator.py +53 -0
  23. gain_core-2026.10.2/gain/annotation/effect_annotator.py +339 -0
  24. gain_core-2026.10.2/gain/annotation/fragment_score_annotator.py +291 -0
  25. gain_core-2026.10.2/gain/annotation/gene_score_annotator.py +148 -0
  26. gain_core-2026.10.2/gain/annotation/gene_set_annotator.py +170 -0
  27. gain_core-2026.10.2/gain/annotation/genomic_score_annotator_base.py +244 -0
  28. gain_core-2026.10.2/gain/annotation/liftover_annotator.py +536 -0
  29. gain_core-2026.10.2/gain/annotation/normalize_allele_annotator.py +86 -0
  30. gain_core-2026.10.2/gain/annotation/pipeline_doc.py +180 -0
  31. gain_core-2026.10.2/gain/annotation/position_score_annotator.py +186 -0
  32. gain_core-2026.10.2/gain/annotation/prepare_tabular.py +736 -0
  33. gain_core-2026.10.2/gain/annotation/processing_pipeline.py +207 -0
  34. gain_core-2026.10.2/gain/annotation/record_to_annotatable.py +277 -0
  35. gain_core-2026.10.2/gain/annotation/simple_effect_annotator.py +319 -0
  36. gain_core-2026.10.2/gain/annotation/utils.py +141 -0
  37. gain_core-2026.10.2/gain/annotation/value_transform_eval.py +375 -0
  38. gain_core-2026.10.2/gain/binning/__init__.py +1 -0
  39. gain_core-2026.10.2/gain/binning/binners.py +663 -0
  40. gain_core-2026.10.2/gain/binning/cli.py +559 -0
  41. gain_core-2026.10.2/gain/binning/fragment_binner.py +1496 -0
  42. gain_core-2026.10.2/gain/binning/fragment_def.py +52 -0
  43. gain_core-2026.10.2/gain/binning/fragment_folds.py +393 -0
  44. gain_core-2026.10.2/gain/binning/h5_reader.py +175 -0
  45. gain_core-2026.10.2/gain/binning/position_fold.py +375 -0
  46. gain_core-2026.10.2/gain/binning/run_definition.py +253 -0
  47. gain_core-2026.10.2/gain/binning/view_cli.py +303 -0
  48. gain_core-2026.10.2/gain/dask/__init__.py +2 -0
  49. gain_core-2026.10.2/gain/dask/config.py +265 -0
  50. gain_core-2026.10.2/gain/dask/named_cluster.py +281 -0
  51. gain_core-2026.10.2/gain/dask/named_cluster.yaml +95 -0
  52. gain_core-2026.10.2/gain/effect_annotation/README.md +68 -0
  53. gain_core-2026.10.2/gain/effect_annotation/__init__.py +0 -0
  54. gain_core-2026.10.2/gain/effect_annotation/annotation_effects.py +116 -0
  55. gain_core-2026.10.2/gain/effect_annotation/annotation_request.py +561 -0
  56. gain_core-2026.10.2/gain/effect_annotation/annotator.py +279 -0
  57. gain_core-2026.10.2/gain/effect_annotation/cli.py +451 -0
  58. gain_core-2026.10.2/gain/effect_annotation/effect.py +888 -0
  59. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/__init__.py +0 -0
  60. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/coding.py +32 -0
  61. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/effect_checker.py +13 -0
  62. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/frame_shift.py +107 -0
  63. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/intron.py +57 -0
  64. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/promoter.py +82 -0
  65. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/protein_change.py +45 -0
  66. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/splice_site.py +56 -0
  67. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/start_loss.py +31 -0
  68. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/stop_loss.py +45 -0
  69. gain_core-2026.10.2/gain/effect_annotation/effect_checkers/utr.py +122 -0
  70. gain_core-2026.10.2/gain/effect_annotation/gene_codes.py +35 -0
  71. gain_core-2026.10.2/gain/effect_annotation/variant.py +152 -0
  72. gain_core-2026.10.2/gain/gene_scores/__init__.py +0 -0
  73. gain_core-2026.10.2/gain/gene_scores/gene_scores.py +650 -0
  74. gain_core-2026.10.2/gain/gene_scores/implementations/__init__.py +0 -0
  75. gain_core-2026.10.2/gain/gene_scores/implementations/gene_scores_impl.py +170 -0
  76. gain_core-2026.10.2/gain/gene_sets/__init__.py +0 -0
  77. gain_core-2026.10.2/gain/gene_sets/gene_set.py +607 -0
  78. gain_core-2026.10.2/gain/gene_sets/gene_term.py +320 -0
  79. gain_core-2026.10.2/gain/gene_sets/implementations/__init__.py +0 -0
  80. gain_core-2026.10.2/gain/gene_sets/implementations/gene_sets_impl.py +328 -0
  81. gain_core-2026.10.2/gain/genomic_resources/__init__.py +100 -0
  82. gain_core-2026.10.2/gain/genomic_resources/aggregators.py +1027 -0
  83. gain_core-2026.10.2/gain/genomic_resources/allele_classification.py +103 -0
  84. gain_core-2026.10.2/gain/genomic_resources/ann_data_10x.py +600 -0
  85. gain_core-2026.10.2/gain/genomic_resources/ann_data_resource.py +405 -0
  86. gain_core-2026.10.2/gain/genomic_resources/bigwig_scores.py +228 -0
  87. gain_core-2026.10.2/gain/genomic_resources/cached_repository.py +1121 -0
  88. gain_core-2026.10.2/gain/genomic_resources/cli.py +1769 -0
  89. gain_core-2026.10.2/gain/genomic_resources/cli_cache_repo.py +84 -0
  90. gain_core-2026.10.2/gain/genomic_resources/cli_dvc.py +103 -0
  91. gain_core-2026.10.2/gain/genomic_resources/cli_errors.py +70 -0
  92. gain_core-2026.10.2/gain/genomic_resources/cli_list.py +139 -0
  93. gain_core-2026.10.2/gain/genomic_resources/data_frame_resource.py +161 -0
  94. gain_core-2026.10.2/gain/genomic_resources/draw_score_histograms.py +207 -0
  95. gain_core-2026.10.2/gain/genomic_resources/dvc.py +150 -0
  96. gain_core-2026.10.2/gain/genomic_resources/fsspec_protocol.py +3531 -0
  97. gain_core-2026.10.2/gain/genomic_resources/gene_models/__init__.py +21 -0
  98. gain_core-2026.10.2/gain/genomic_resources/gene_models/default_attributes.py +83 -0
  99. gain_core-2026.10.2/gain/genomic_resources/gene_models/gene_models.py +496 -0
  100. gain_core-2026.10.2/gain/genomic_resources/gene_models/gene_models_factory.py +147 -0
  101. gain_core-2026.10.2/gain/genomic_resources/gene_models/parsers.py +1346 -0
  102. gain_core-2026.10.2/gain/genomic_resources/gene_models/record_cells.py +315 -0
  103. gain_core-2026.10.2/gain/genomic_resources/gene_models/serialization.py +541 -0
  104. gain_core-2026.10.2/gain/genomic_resources/gene_models/to_gpf_gene_models_format.py +63 -0
  105. gain_core-2026.10.2/gain/genomic_resources/gene_models/transcript_models.py +791 -0
  106. gain_core-2026.10.2/gain/genomic_resources/genomic_context.py +340 -0
  107. gain_core-2026.10.2/gain/genomic_resources/genomic_context_base.py +457 -0
  108. gain_core-2026.10.2/gain/genomic_resources/genomic_context_cli.py +172 -0
  109. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/__init__.py +886 -0
  110. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/index_columns.py +103 -0
  111. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/line.py +368 -0
  112. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/record.py +212 -0
  113. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table.py +966 -0
  114. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_bigwig.py +469 -0
  115. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_inmemory.py +336 -0
  116. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_tabix.py +1027 -0
  117. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_vcf.py +330 -0
  118. gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/utils.py +162 -0
  119. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/__init__.py +128 -0
  120. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/aggregation.py +434 -0
  121. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/allele.py +1641 -0
  122. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/base.py +1598 -0
  123. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/batch_budget.py +32 -0
  124. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/builders.py +298 -0
  125. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/chrom_lengths.py +486 -0
  126. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/fragment.py +1134 -0
  127. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/position.py +978 -0
  128. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/records.py +205 -0
  129. gain_core-2026.10.2/gain/genomic_resources/genomic_scores/value_extraction.py +209 -0
  130. gain_core-2026.10.2/gain/genomic_resources/group_repository.py +296 -0
  131. gain_core-2026.10.2/gain/genomic_resources/histogram.py +2063 -0
  132. gain_core-2026.10.2/gain/genomic_resources/implementations/__init__.py +0 -0
  133. gain_core-2026.10.2/gain/genomic_resources/implementations/ann_data_resource_impl.py +230 -0
  134. gain_core-2026.10.2/gain/genomic_resources/implementations/annotation_pipeline_impl.py +115 -0
  135. gain_core-2026.10.2/gain/genomic_resources/implementations/basic_resource_impl.py +73 -0
  136. gain_core-2026.10.2/gain/genomic_resources/implementations/data_frame_resource_impl.py +144 -0
  137. gain_core-2026.10.2/gain/genomic_resources/implementations/gene_models_impl.py +190 -0
  138. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/__init__.py +49 -0
  139. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/allele.py +73 -0
  140. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/base.py +615 -0
  141. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/builders.py +43 -0
  142. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/fragment.py +69 -0
  143. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/position.py +114 -0
  144. gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/scan.py +1254 -0
  145. gain_core-2026.10.2/gain/genomic_resources/implementations/liftover_chain_impl.py +93 -0
  146. gain_core-2026.10.2/gain/genomic_resources/implementations/reference_genome_impl.py +617 -0
  147. gain_core-2026.10.2/gain/genomic_resources/index_search_grammar.ne +36 -0
  148. gain_core-2026.10.2/gain/genomic_resources/liftover_chain.py +301 -0
  149. gain_core-2026.10.2/gain/genomic_resources/memo.py +88 -0
  150. gain_core-2026.10.2/gain/genomic_resources/reference_genome.py +669 -0
  151. gain_core-2026.10.2/gain/genomic_resources/repository.py +3514 -0
  152. gain_core-2026.10.2/gain/genomic_resources/repository_factory.py +948 -0
  153. gain_core-2026.10.2/gain/genomic_resources/resource_errors.py +273 -0
  154. gain_core-2026.10.2/gain/genomic_resources/resource_implementation.py +951 -0
  155. gain_core-2026.10.2/gain/genomic_resources/resource_query.py +313 -0
  156. gain_core-2026.10.2/gain/genomic_resources/resource_types.py +479 -0
  157. gain_core-2026.10.2/gain/genomic_resources/score_def.py +966 -0
  158. gain_core-2026.10.2/gain/genomic_resources/score_filter.py +388 -0
  159. gain_core-2026.10.2/gain/genomic_resources/score_implementation.py +270 -0
  160. gain_core-2026.10.2/gain/genomic_resources/score_resource.py +488 -0
  161. gain_core-2026.10.2/gain/genomic_resources/statistics/__init__.py +0 -0
  162. gain_core-2026.10.2/gain/genomic_resources/statistics/alleles.py +1445 -0
  163. gain_core-2026.10.2/gain/genomic_resources/statistics/base_statistic.py +286 -0
  164. gain_core-2026.10.2/gain/genomic_resources/statistics/chart_style.py +17 -0
  165. gain_core-2026.10.2/gain/genomic_resources/statistics/coverage.py +1115 -0
  166. gain_core-2026.10.2/gain/genomic_resources/statistics/exact_lengths.py +650 -0
  167. gain_core-2026.10.2/gain/genomic_resources/statistics/fragments.py +408 -0
  168. gain_core-2026.10.2/gain/genomic_resources/statistics/length_histogram.py +128 -0
  169. gain_core-2026.10.2/gain/genomic_resources/statistics/min_max.py +165 -0
  170. gain_core-2026.10.2/gain/genomic_resources/statistics/moments.py +169 -0
  171. gain_core-2026.10.2/gain/genomic_resources/statistics/percentages.py +88 -0
  172. gain_core-2026.10.2/gain/genomic_resources/statistics/record_validation.py +374 -0
  173. gain_core-2026.10.2/gain/genomic_resources/statistics/region_fold.py +60 -0
  174. gain_core-2026.10.2/gain/genomic_resources/testing/__init__.py +861 -0
  175. gain_core-2026.10.2/gain/genomic_resources/testing/ann_data_builder.py +568 -0
  176. gain_core-2026.10.2/gain/genomic_resources/testing/annotation_pipeline_builder.py +148 -0
  177. gain_core-2026.10.2/gain/genomic_resources/testing/builders.py +2304 -0
  178. gain_core-2026.10.2/gain/genomic_resources/testing/data_frame_builder.py +260 -0
  179. gain_core-2026.10.2/gain/genomic_resources/testing/extra_files.py +79 -0
  180. gain_core-2026.10.2/gain/genomic_resources/testing/faulty_filesystem.py +426 -0
  181. gain_core-2026.10.2/gain/genomic_resources/testing/gene_models_builder.py +614 -0
  182. gain_core-2026.10.2/gain/genomic_resources/testing/gene_set_collection_builder.py +173 -0
  183. gain_core-2026.10.2/gain/genomic_resources/testing/group_builder.py +164 -0
  184. gain_core-2026.10.2/gain/genomic_resources/testing/info_page_fixtures.py +259 -0
  185. gain_core-2026.10.2/gain/genomic_resources/testing/liftover_chain_builder.py +113 -0
  186. gain_core-2026.10.2/gain/genomic_resources/testing/resource_meta.py +190 -0
  187. gain_core-2026.10.2/gain/genomic_resources/testing/score_specs.py +278 -0
  188. gain_core-2026.10.2/gain/genomic_resources/testing/statistics.py +138 -0
  189. gain_core-2026.10.2/gain/genomic_resources/utils.py +135 -0
  190. gain_core-2026.10.2/gain/genomic_resources/variant_utils.py +96 -0
  191. gain_core-2026.10.2/gain/genomic_resources/vcf_scores.py +752 -0
  192. gain_core-2026.10.2/gain/grr/__init__.py +127 -0
  193. gain_core-2026.10.2/gain/logging.py +68 -0
  194. gain_core-2026.10.2/gain/py.typed +0 -0
  195. gain_core-2026.10.2/gain/task_graph/__init__.py +3 -0
  196. gain_core-2026.10.2/gain/task_graph/base_executor.py +367 -0
  197. gain_core-2026.10.2/gain/task_graph/cache.py +369 -0
  198. gain_core-2026.10.2/gain/task_graph/cli_tools.py +497 -0
  199. gain_core-2026.10.2/gain/task_graph/dask_executor.py +479 -0
  200. gain_core-2026.10.2/gain/task_graph/dask_run_state.py +490 -0
  201. gain_core-2026.10.2/gain/task_graph/demo_graphs_cli.py +197 -0
  202. gain_core-2026.10.2/gain/task_graph/executor.py +95 -0
  203. gain_core-2026.10.2/gain/task_graph/graph.py +794 -0
  204. gain_core-2026.10.2/gain/task_graph/logging.py +100 -0
  205. gain_core-2026.10.2/gain/task_graph/process_pool_executor.py +166 -0
  206. gain_core-2026.10.2/gain/task_graph/sequential_executor.py +52 -0
  207. gain_core-2026.10.2/gain/task_graph/work_dir.py +120 -0
  208. gain_core-2026.10.2/gain/templates/__init__.py +197 -0
  209. gain_core-2026.10.2/gain/templates/breadcrumb.py +72 -0
  210. gain_core-2026.10.2/gain/templates/markdown_support.py +159 -0
  211. gain_core-2026.10.2/gain/templates/static/fonts/LICENSE-Material-Symbols.txt +177 -0
  212. gain_core-2026.10.2/gain/templates/static/fonts/LICENSE-Roboto.txt +93 -0
  213. gain_core-2026.10.2/gain/templates/static/fonts/README.md +102 -0
  214. gain_core-2026.10.2/gain/templates/static/fonts/material-symbols-outlined-v371.woff2 +0 -0
  215. gain_core-2026.10.2/gain/templates/static/fonts/roboto-v51-latin.woff2 +0 -0
  216. gain_core-2026.10.2/gain/templates/static/sqlite-wasm/LICENSE +177 -0
  217. gain_core-2026.10.2/gain/templates/static/sqlite-wasm/README.md +57 -0
  218. gain_core-2026.10.2/gain/templates/static/sqlite-wasm/index.mjs +10650 -0
  219. gain_core-2026.10.2/gain/templates/static/sqlite-wasm/sqlite3.wasm +0 -0
  220. gain_core-2026.10.2/gain/templates/static/sqlite-wasm/version.txt +1 -0
  221. gain_core-2026.10.2/gain/templates/static_assets.py +147 -0
  222. gain_core-2026.10.2/gain/templates/template_files/.keep +0 -0
  223. gain_core-2026.10.2/gain/templates/template_files/allele_score.jinja +222 -0
  224. gain_core-2026.10.2/gain/templates/template_files/ann_data.jinja +38 -0
  225. gain_core-2026.10.2/gain/templates/template_files/annotate_doc_pipeline_template.jinja +261 -0
  226. gain_core-2026.10.2/gain/templates/template_files/annotation_pipeline.jinja +5 -0
  227. gain_core-2026.10.2/gain/templates/template_files/base_implementation.jinja +4 -0
  228. gain_core-2026.10.2/gain/templates/template_files/base_implementation_styles.jinja +0 -0
  229. gain_core-2026.10.2/gain/templates/template_files/base_styles.jinja +174 -0
  230. gain_core-2026.10.2/gain/templates/template_files/basic.jinja +3 -0
  231. gain_core-2026.10.2/gain/templates/template_files/breadcrumb.jinja +28 -0
  232. gain_core-2026.10.2/gain/templates/template_files/breadcrumb_styles.jinja +42 -0
  233. gain_core-2026.10.2/gain/templates/template_files/content_styles.jinja +106 -0
  234. gain_core-2026.10.2/gain/templates/template_files/copy_button.jinja +31 -0
  235. gain_core-2026.10.2/gain/templates/template_files/copy_button_styles.jinja +13 -0
  236. gain_core-2026.10.2/gain/templates/template_files/data_frame.jinja +13 -0
  237. gain_core-2026.10.2/gain/templates/template_files/fragment_score.jinja +57 -0
  238. gain_core-2026.10.2/gain/templates/template_files/gene_models.jinja +40 -0
  239. gain_core-2026.10.2/gain/templates/template_files/gene_models_styles.jinja +0 -0
  240. gain_core-2026.10.2/gain/templates/template_files/gene_score.jinja +99 -0
  241. gain_core-2026.10.2/gain/templates/template_files/gene_score_help.jinja +16 -0
  242. gain_core-2026.10.2/gain/templates/template_files/gene_score_styles.jinja +3 -0
  243. gain_core-2026.10.2/gain/templates/template_files/gene_set_collection.jinja +78 -0
  244. gain_core-2026.10.2/gain/templates/template_files/gene_set_collection_styles.jinja +9 -0
  245. gain_core-2026.10.2/gain/templates/template_files/genomic_score.jinja +130 -0
  246. gain_core-2026.10.2/gain/templates/template_files/genomic_score_help.jinja +50 -0
  247. gain_core-2026.10.2/gain/templates/template_files/genomic_score_styles.jinja +3 -0
  248. gain_core-2026.10.2/gain/templates/template_files/grr_about.jinja +79 -0
  249. gain_core-2026.10.2/gain/templates/template_files/grr_index.jinja +548 -0
  250. gain_core-2026.10.2/gain/templates/template_files/grr_scripts.jinja +1643 -0
  251. gain_core-2026.10.2/gain/templates/template_files/icon_font.jinja +47 -0
  252. gain_core-2026.10.2/gain/templates/template_files/length_statistics.jinja +82 -0
  253. gain_core-2026.10.2/gain/templates/template_files/liftover_chain.jinja +15 -0
  254. gain_core-2026.10.2/gain/templates/template_files/moments_summary.jinja +19 -0
  255. gain_core-2026.10.2/gain/templates/template_files/position_score.jinja +150 -0
  256. gain_core-2026.10.2/gain/templates/template_files/reference_genome.jinja +75 -0
  257. gain_core-2026.10.2/gain/templates/template_files/reference_genome_styles.jinja +3 -0
  258. gain_core-2026.10.2/gain/templates/template_files/resource_template.jinja +243 -0
  259. gain_core-2026.10.2/gain/templates/template_files/roboto_font.jinja +31 -0
  260. gain_core-2026.10.2/gain/templates/template_files/score_histogram.jinja +12 -0
  261. gain_core-2026.10.2/gain/templates/template_files/sortable_table.jinja +210 -0
  262. gain_core-2026.10.2/gain/templates/template_files/statistics_template.jinja +54 -0
  263. gain_core-2026.10.2/gain/testing/__init__.py +0 -0
  264. gain_core-2026.10.2/gain/testing/acgt_import.py +37 -0
  265. gain_core-2026.10.2/gain/testing/alla_import.py +41 -0
  266. gain_core-2026.10.2/gain/testing/foobar_import.py +39 -0
  267. gain_core-2026.10.2/gain/testing/t4c8_import.py +146 -0
  268. gain_core-2026.10.2/gain/utils/__init__.py +0 -0
  269. gain_core-2026.10.2/gain/utils/chromosome_order.py +68 -0
  270. gain_core-2026.10.2/gain/utils/cnv_utils.py +29 -0
  271. gain_core-2026.10.2/gain/utils/dae_utils.py +74 -0
  272. gain_core-2026.10.2/gain/utils/debug_closing.py +65 -0
  273. gain_core-2026.10.2/gain/utils/dict_utils.py +45 -0
  274. gain_core-2026.10.2/gain/utils/fs_utils.py +243 -0
  275. gain_core-2026.10.2/gain/utils/helpers.py +64 -0
  276. gain_core-2026.10.2/gain/utils/log_levels.py +75 -0
  277. gain_core-2026.10.2/gain/utils/log_safety.py +44 -0
  278. gain_core-2026.10.2/gain/utils/processing_pipeline.py +81 -0
  279. gain_core-2026.10.2/gain/utils/regions.py +645 -0
  280. gain_core-2026.10.2/gain/utils/resource_id_order.py +49 -0
  281. gain_core-2026.10.2/gain/utils/stats_collection.py +75 -0
  282. gain_core-2026.10.2/gain/utils/stringify.py +44 -0
  283. gain_core-2026.10.2/gain/utils/url_redaction.py +150 -0
  284. gain_core-2026.10.2/gain/utils/variant_utils.py +113 -0
  285. gain_core-2026.10.2/gain/utils/verbosity_configuration.py +58 -0
  286. gain_core-2026.10.2/gain/utils/zulip_logging.py +265 -0
  287. gain_core-2026.10.2/pyproject.toml +194 -0
@@ -0,0 +1,113 @@
1
+ # A .claude directory at any depth is ignored (Claude Code started from a
2
+ # member project writes <member>/.claude/settings.local.json). The root one is
3
+ # un-ignored only so that its committed skills/ can be re-included;
4
+ # .claude/worktrees/ and the rest of the root .claude stay ignored.
5
+ **/.claude/
6
+ !/.claude/
7
+ /.claude/*
8
+ !/.claude/skills/
9
+ # verify-gain run output (.claude/skills/verify-gain)
10
+ .verify/
11
+ .specify
12
+ *.pyc
13
+ __pycache__
14
+ .cache
15
+ .DS_Store
16
+ ._.DS_Store
17
+ *.log
18
+ *.cache
19
+ *.db
20
+ *.tmp
21
+ *.temp
22
+ *.swp
23
+ *.retry
24
+ *.egg-info
25
+
26
+ .project
27
+ .pydevproject
28
+ .settings
29
+ .ipynb_checkpoints
30
+ .vagrant
31
+ .vscode/
32
+ .idea/
33
+
34
+ .coverage
35
+ .coverage*
36
+ coverage/
37
+ coverage.xml
38
+ htmlcov
39
+ junit.xml
40
+ .pytest_cache
41
+ .mypy_cache
42
+
43
+ logs
44
+ output
45
+ tmp/
46
+ builds
47
+ downloads
48
+ results
49
+ test_data/
50
+ /test_data/
51
+ test-results/
52
+ /test-results
53
+ test_results
54
+ comp-data/
55
+ comp
56
+ cache
57
+ import
58
+ /import
59
+ _build/
60
+ _html
61
+ denovo-cache
62
+ dask-worker-space/
63
+ .grr
64
+ /data/
65
+ /build-env/
66
+ build-env/*
67
+ projects
68
+ /work
69
+
70
+ Jenkinsfile.generated-stages
71
+ Jenkinsfile.generated-stages.all
72
+ /.build-scripts-tmp-sessions
73
+
74
+ monkeytype.sqlite3
75
+ monkeytype_config.py
76
+
77
+ VERSION
78
+ BUILD
79
+
80
+ CLAUDE*.md
81
+
82
+ .task-progress
83
+
84
+ # uv-managed virtual environment
85
+ .venv/
86
+
87
+ # Generated by hatch-vcs at build/install time
88
+ core/gain/_version.py
89
+
90
+ # Root-level build artefact dirs created by the root Jenkinsfile
91
+ # (uv build wheels, rattler-build conda packages). Cleaned and
92
+ # re-created in CI's `Prepare workspace` stage; never checked in.
93
+ /dist/
94
+ /conda/
95
+ /reports/
96
+ web_api/data/db.sqlite3
97
+
98
+ # Linked git worktrees used by Claude Code for isolated
99
+ # feature development (see superpowers `using-git-worktrees`).
100
+ /.worktrees/
101
+
102
+ # Sphinx docs build artefacts. The tarball is consumed by
103
+ # docs/deploy/docs_deploy.yaml; both are produced by
104
+ # docs/build_docs.sh.
105
+ /docs/build/
106
+ /docs/gaindocs-html.tar.gz
107
+ /docs/.tmp/
108
+
109
+ # Running the spliceai tests opens this fixture directory as a GRR, which
110
+ # writes a compressed contents index beside the authored `.CONTENTS.json`.
111
+ # Only this one path: `web_api`'s fixture GRR tracks its `.CONTENTS.*.gz`
112
+ # on purpose, so this must not be a repo-wide pattern.
113
+ /spliceai_annotator/tests/fixtures/.CONTENTS.json.gz
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.5
2
+ Name: gain-core
3
+ Version: 2026.10.2
4
+ Summary: GAIn: Genomic Annotation Infrastructure
5
+ Project-URL: Homepage, https://github.com/IossifovLab/gain
6
+ Author-email: Lubomir Chorbadjiev <lubomir.chorbadjiev@gmail.com>
7
+ License: MIT
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: anndata>=0.13
14
+ Requires-Dist: apsw>=3.52
15
+ Requires-Dist: cerberus>=1.3
16
+ Requires-Dist: dask-jobqueue>=0.9
17
+ Requires-Dist: dask>=2026.1
18
+ Requires-Dist: distributed>=2026.1
19
+ Requires-Dist: docker>=7.1
20
+ Requires-Dist: filelock>=3.19
21
+ Requires-Dist: fsspec>=2026.2
22
+ Requires-Dist: h5py>=3.11
23
+ Requires-Dist: intervaltree
24
+ Requires-Dist: jinja2>=3.1
25
+ Requires-Dist: lark>=1.2
26
+ Requires-Dist: markdown2>=2.4
27
+ Requires-Dist: matplotlib>=3.8
28
+ Requires-Dist: networkx>=3.6
29
+ Requires-Dist: numpy>=2.2
30
+ Requires-Dist: openpyxl>=3.1
31
+ Requires-Dist: packaging
32
+ Requires-Dist: pandas>=2.2
33
+ Requires-Dist: pathspec>=1.0
34
+ Requires-Dist: psutil
35
+ Requires-Dist: pybigwig>=0.3
36
+ Requires-Dist: pydantic>=2.8
37
+ Requires-Dist: pyliftover>=0.4
38
+ Requires-Dist: pysam>=0.24
39
+ Requires-Dist: python-box>=7.1
40
+ Requires-Dist: pyyaml>=6
41
+ Requires-Dist: s3fs>=2026.2
42
+ Requires-Dist: scipy>=1.14
43
+ Requires-Dist: tqdm>=4.66
44
+ Description-Content-Type: text/markdown
45
+
46
+ ## GAIn: Genomic Annotation Infrastructure
47
+
48
+ Annotation is a core step in genomic analysis: sequencing gives you a list of observed variants, and annotation adds the biological and clinical context needed to interpret them. GAIn is an infrastructure for running annotation in a consistent, reproducible way—by combining curated resources (genomes, gene models, scores, gene sets, and plugins) with a user-defined annotation pipeline that specifies what to compute and what to emit. This documentation walks through how to use GAIn end to end: getting started on the web and the CLI, discovering and building Genomic Resource Repositories (GRRs), configuring resources, writing and running annotation pipelines, and using the web and Python interfaces.
49
+
50
+ Information on how to use GPF could be found in the
51
+ [GAIn documentation](https://iossifovlab.com/gaindocs/)
@@ -0,0 +1,6 @@
1
+ ## GAIn: Genomic Annotation Infrastructure
2
+
3
+ Annotation is a core step in genomic analysis: sequencing gives you a list of observed variants, and annotation adds the biological and clinical context needed to interpret them. GAIn is an infrastructure for running annotation in a consistent, reproducible way—by combining curated resources (genomes, gene models, scores, gene sets, and plugins) with a user-defined annotation pipeline that specifies what to compute and what to emit. This documentation walks through how to use GAIn end to end: getting started on the web and the CLI, discovering and building Genomic Resource Repositories (GRRs), configuring resources, writing and running annotation pipelines, and using the web and Python interfaces.
4
+
5
+ Information on how to use GPF could be found in the
6
+ [GAIn documentation](https://iossifovlab.com/gaindocs/)
@@ -0,0 +1,14 @@
1
+ try:
2
+ from ._version import __version__
3
+ except ImportError:
4
+ # _version.py is generated by hatch-vcs into the built wheel. It may be
5
+ # absent when gain-core is installed editable from a source checkout
6
+ # (e.g. inside CI Docker images that don't ship .git).
7
+ __version__ = "0.0.0.dev0"
8
+
9
+ # Both configure stdlib logging for the whole process as an import side
10
+ # effect: the custom levels, and the log-record seam that renders every log
11
+ # line without url userinfo (ADR 0023, gain#1363). Importing gain at all is
12
+ # the moment, so no worker, host or later import order can miss either.
13
+ import gain.utils.log_levels # ruff: ignore[unused-import]
14
+ import gain.utils.url_redaction # ruff: ignore[unused-import]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '2026.10.2'
22
+ __version_tuple__ = version_tuple = (2026, 10, 2)
23
+
24
+ __commit_id__ = commit_id = None
@@ -0,0 +1,38 @@
1
+ * Misc
2
+ - Implement the assert for the correct resource_type for PositionScore and AlleleScore
3
+ - Categorical histogram
4
+ - Range column in the genomic scores' index.html.
5
+ - Talk again about the min-max values.
6
+ - Hack to update statis_hash without re-runing the stats
7
+
8
+ * score resource
9
+ - should return None when a histogram file is not created.
10
+
11
+ * rename annotators
12
+ - effect_annotator -> gpf_effect
13
+ - liftover_annotator -> liftover
14
+
15
+ * updated the font sized in the pipeline documentation:
16
+ - larger fonts for the attribute names
17
+ - smaller fonts for the annotators
18
+
19
+ * score annotator
20
+ - re-organized the responsibilities for generatonr score documentation
21
+ - the ScoreResource itself should bult some of the documentatio and the annotator should add the annotator specific options, like the aggregators.
22
+ - configure completely few of the score resources
23
+ - create a brange in the ivan's local grr repo
24
+ - copy the available docuemntation from dbSNP
25
+ - re-implemenet the aggregator documentation by using the score resources implementation
26
+
27
+ * GRR index page
28
+ - make sure that resources provide two properties:
29
+ - summary
30
+ - description
31
+ (OR description and documentation)
32
+ - make sure that only the resoruce "summary" is included ine index.
33
+
34
+ * gpf_effect annotator
35
+ - implement the <effect>_genes attributes
36
+ - implement the <effect>_transcripts attributes
37
+ - add the appropriate annotator documentation
38
+
File without changes
@@ -0,0 +1,384 @@
1
+ """The ``allele_score_annotator``.
2
+
3
+ Annotates with scores keyed by allele -- frequencies, pathogenicity
4
+ predictions and the like -- read from an ``allele_score`` resource, by
5
+ exact allele match or reduced over a region.
6
+ """
7
+ import textwrap
8
+ from typing import Any
9
+
10
+ from gain.annotation.annotatable import Annotatable, VCFAllele
11
+ from gain.annotation.annotation_config import (
12
+ AnnotationConfigurationError,
13
+ AnnotatorInfo,
14
+ Attribute,
15
+ )
16
+ from gain.annotation.annotation_pipeline import (
17
+ AnnotationPipeline,
18
+ Annotator,
19
+ AttributeSpec,
20
+ )
21
+ from gain.annotation.annotator_base import AnnotatedValues
22
+ from gain.annotation.genomic_score_annotator_base import (
23
+ GenomicScoreAnnotatorBase,
24
+ )
25
+ from gain.genomic_resources.aggregators import (
26
+ ScoreAggregationQuery,
27
+ )
28
+ from gain.genomic_resources.genomic_scores import (
29
+ AlleleAggregate,
30
+ AlleleScore,
31
+ allele_key,
32
+ build_allele_score_from_resource,
33
+ )
34
+ from gain.genomic_resources.resource_types import (
35
+ PREFERRED_ALLELE_SCORE_TYPE,
36
+ )
37
+ from gain.genomic_resources.score_filter import ScoreFilterError
38
+
39
+
40
+ def build_allele_score_annotator(pipeline: AnnotationPipeline,
41
+ info: AnnotatorInfo) -> Annotator:
42
+ return AlleleScoreAnnotator(pipeline, info)
43
+
44
+
45
+ class AlleleScoreAnnotator(GenomicScoreAnnotatorBase):
46
+ """Annotator for allele-level genomic scores (frequencies, pathogenicity…).
47
+
48
+ Operates in one of two modes, selected by the ``mode`` parameter:
49
+
50
+ - ``allele`` (**default**): a ``VCFAllele`` the resource keys as a line
51
+ of its own gets an exact chrom/pos/ref/alt lookup, exact on the
52
+ position too. On a resource declaring ``allele_multiplicity: one``
53
+ -- the default -- that is the allele's only line and its scores
54
+ (``AlleleScore.get_allele_scores_for_allele``); on a ``many``
55
+ resource the allele's lines are reduced, each attribute by its
56
+ aggregator, as a region fold reduces them
57
+ (``AlleleScore.get_allele_scores_for_allele_agg``). Which alleles
58
+ are matched is the resource's
59
+ ``allele_score_mode``: every ``VCFAllele`` on an ``alleles``
60
+ resource, only a substitution on a ``substitutions`` one. Any other
61
+ ``VCFAllele`` -- an indel or complex allele on a ``substitutions``
62
+ resource -- takes the ``region`` path over the bases it covers,
63
+ subject to ``region_length_cutoff``, as does every annotatable that
64
+ is not a ``VCFAllele``.
65
+
66
+ - ``region``: the score reduces all allele lines that overlap the
67
+ annotatable's span, in one streaming walk
68
+ (``AlleleScore.get_allele_scores_in_region_agg``). Works with any
69
+ ``Annotatable`` (``VCFAllele``, ``Region``, CNV, …), and folds every
70
+ ``VCFAllele`` whatever the resource's mode, subject to
71
+ ``region_length_cutoff``. An aggregator
72
+ must be defined for every score attribute, either in the attribute
73
+ config or as the score's ``aggregator`` default in the resource YAML;
74
+ an attribute with neither -- only a ``bool`` score can be in that
75
+ position -- is refused when the pipeline loads, in either mode,
76
+ because a CNV or a region takes the region path whatever the mode.
77
+
78
+ Virtual ``allele`` attribute
79
+ ----------------------------
80
+ All annotators expose a virtual attribute ``"allele"``
81
+ (``is_default=False``)
82
+ that is synthesised rather than read from the data file.
83
+
84
+ - On an exact match: returns ``["chrom:pos:ref:alt"]`` for the matched
85
+ line. On a ``many`` resource, the distinct keys of the allele's
86
+ lines that pass ``allele_filter`` -- one, or several when an
87
+ ``include_attributes`` score differs across them.
88
+ - On a region fold, in either mode: returns the distinct
89
+ ``"chrom:pos:ref:alt"`` strings of the lines that pass the optional
90
+ ``allele_filter``, in the order the lines were first met -- the
91
+ resource's own genomic order.
92
+
93
+ Optionally append score values to each allele string with
94
+ ``include_attributes``. The string's format is the score's,
95
+ :func:`~gain.genomic_resources.genomic_scores.allele.allele_key`, so
96
+ the two modes cannot drift.
97
+
98
+ An aggregator named on this attribute reduces nothing, in either
99
+ mode. It is not a score: its value is the keys the annotator
100
+ synthesised, and ``region`` mode has always answered them beside the
101
+ reductions rather than as one of them. Exact-match mode used to
102
+ differ -- the base folded its one-element list -- and stopped in
103
+ gain#1133, so the two modes now agree.
104
+
105
+ ``allele_filter``
106
+ -----------------
107
+ An optional annotator-level boolean expression evaluated against each
108
+ record before it is included in the result. The annotator only resolves
109
+ the parameter; the expression language belongs to the score, so see
110
+ :meth:`GenomicScore.compile_filter` for the operators it admits and what
111
+ a name may contain.
112
+ """
113
+
114
+ ACCEPTED_RESOURCE_TYPES = (PREFERRED_ALLELE_SCORE_TYPE,)
115
+
116
+ def __init__(self, pipeline: AnnotationPipeline, info: AnnotatorInfo):
117
+ resource = self.resolve_resource(pipeline, info)
118
+ self.allele_score = build_allele_score_from_resource(resource)
119
+ self.allele_filter = None
120
+ allele_filter_str = info.parameters.get("allele_filter")
121
+ if allele_filter_str is not None:
122
+ assert isinstance(allele_filter_str, str)
123
+
124
+ try:
125
+ self.allele_filter = self.allele_score.compile_filter(
126
+ allele_filter_str)
127
+ except ScoreFilterError as e:
128
+ # Named after the parameter the user wrote: the score knows
129
+ # nothing about how the expression reached it (cf. gain#477).
130
+ raise AnnotationConfigurationError(
131
+ f"Error parsing allele_filter: {e}") from e
132
+
133
+ mode = info.parameters.get("mode", "allele")
134
+ if mode not in {"allele", "region"}:
135
+ raise AnnotationConfigurationError(
136
+ f"Invalid mode '{mode}' for allele_score_annotator; "
137
+ "valid values are 'allele' and 'region'")
138
+ self.mode = mode
139
+
140
+ super().__init__(pipeline, info, self.allele_score)
141
+ info.documentation += textwrap.dedent(f"""
142
+
143
+ Annotator to use with scores that depend on allele like
144
+ variant frequencies, etc.
145
+
146
+ **Mode** (``mode`` parameter, applies to ``VCFAllele`` inputs only):
147
+
148
+ - ``allele`` (default): routed by the resource's ``allele_score_mode``.
149
+ On an ``alleles`` resource every allele is an exact chrom/pos/ref/alt
150
+ match. On a ``substitutions`` resource only a substitution is; an
151
+ insertion, deletion or complex allele aggregates the allele lines over
152
+ the bases it covers.
153
+ - ``region``: aggregates scores for all allele lines overlapping the
154
+ annotatable's span, whatever the resource's mode.
155
+
156
+ Non-``VCFAllele`` annotatables always use region aggregation.
157
+
158
+ <a href="{self.BASE_DOC_URL}#allele-score-annotator" target="_blank">More info</a>
159
+
160
+ """) # ruff: ignore[line-too-long]
161
+
162
+ self.allele_attribute = None
163
+ self.attrs_to_include: list[str] = []
164
+
165
+ for attr in self._attributes:
166
+ if attr.source == "allele":
167
+ attrs_to_include = attr.parameters.get(
168
+ "include_attributes", [])
169
+ if isinstance(attrs_to_include, str):
170
+ attrs_to_include = [attrs_to_include]
171
+ self.attrs_to_include = list(attrs_to_include)
172
+ self.allele_attribute = attr
173
+ continue
174
+ self.add_score_aggregator_documentation(
175
+ attr, "aggregator", attr.aggregator)
176
+
177
+ # One query per SCORE attribute, as `PositionScoreAnnotator` builds
178
+ # its list and for the reasons its query block gives. The virtual
179
+ # `allele` attribute is not a score and asks the read for the keys
180
+ # instead.
181
+ self._region_queries = [
182
+ ScoreAggregationQuery(attr.source, self._query_aggregator(attr))
183
+ for attr in self._attributes
184
+ if attr is not self.allele_attribute
185
+ ]
186
+ # Resolved now for the refusal alone -- at load, in BOTH modes; see
187
+ # the `region` bullet of the class docstring -- and the same for the
188
+ # `include_attributes` ids.
189
+ self.allele_score.resolve_aggregation_queries(self._region_queries)
190
+ self.allele_score.resolve_allele_key_scores(self.attrs_to_include)
191
+ # The scores a `one` resource's exact match reads: the score
192
+ # attributes' and the ones the allele keys are suffixed with.
193
+ self._exact_scores: list[str] = list(dict.fromkeys(
194
+ [*self.simple_score_queries, *self.attrs_to_include],
195
+ )) or self.allele_score.get_all_scores()
196
+
197
+ def get_attribute_defaults(
198
+ self, spec: AttributeSpec,
199
+ ) -> dict[str, Any]:
200
+ defaults = super().get_attribute_defaults(spec)
201
+ if "aggregator" not in defaults:
202
+ score_def = self.allele_score.get_score_definition(spec.source)
203
+ if score_def is not None \
204
+ and score_def.aggregator is not None:
205
+ defaults["aggregator"] = score_def.aggregator
206
+ return defaults
207
+
208
+ def get_attribute_specs(self) -> dict[str, AttributeSpec]:
209
+ """Return score attribute specs plus the virtual ``allele``."""
210
+ result = super().get_attribute_specs()
211
+ result["allele"] = AttributeSpec(
212
+ source="allele",
213
+ value_type="list",
214
+ description="The allele in the format 'chr:pos:ref:alt'",
215
+ is_default=False,
216
+ internal_default=False,
217
+ )
218
+ return result
219
+
220
+ def build_score_aggregator_documentation(
221
+ self, attr: Attribute,
222
+ ) -> list[str]:
223
+ """Collect score aggregator documentation."""
224
+ allele_doc = self._build_score_aggregator_documentation(
225
+ attr, "aggregator", attr.aggregator,
226
+ )
227
+ return [allele_doc]
228
+
229
+ def _annotate_allele(
230
+ self, annotatable: VCFAllele,
231
+ ) -> AnnotatedValues:
232
+ """Answer an exact chrom/pos/ref/alt match off the allele plane.
233
+
234
+ Read by the resource's ``allele_multiplicity``: the allele's only
235
+ row on a ``one`` resource, its rows folded on a ``many`` one.
236
+ Either way the match is exact on the position too, so a row
237
+ starting before ``pos`` whose span reaches it is not the allele.
238
+ """
239
+ if self.allele_score.multiplicity is AlleleScore.Multiplicity.MANY:
240
+ return self._annotate_allele_rows(annotatable)
241
+ return self._annotate_allele_row(annotatable)
242
+
243
+ def _annotate_allele_row(
244
+ self, annotatable: VCFAllele,
245
+ ) -> AnnotatedValues:
246
+ """Answer the only row of one allele on a ``one`` resource.
247
+
248
+ The row's values as they stand, nothing folded; ``None`` under
249
+ every attribute when no row holds the allele or the filter rejects
250
+ it.
251
+ """
252
+ values = self.allele_score.get_allele_scores_for_allele(
253
+ annotatable.chrom,
254
+ annotatable.position,
255
+ annotatable.reference,
256
+ annotatable.alternative,
257
+ scores=self._exact_scores,
258
+ score_filter=self.allele_filter,
259
+ )
260
+ if values is None:
261
+ return self._empty_result()
262
+ # Widened, because the virtual `allele` attribute below is a LIST of
263
+ # strings and the score's own values are scalars.
264
+ scores: dict[str, Any] = dict(
265
+ zip(self._exact_scores, values, strict=True))
266
+
267
+ if self.allele_attribute is not None:
268
+ # The same helper the region read builds its keys with, so
269
+ # the two paths spell an allele identically.
270
+ scores[self.allele_attribute.source] = [allele_key(
271
+ annotatable.chromosome, annotatable.position,
272
+ annotatable.reference, annotatable.alternative,
273
+ [scores[a] for a in self.attrs_to_include])]
274
+
275
+ # Not ``fold_own_values``: the virtual ``allele`` attribute's
276
+ # key list is the answer, not something to reduce.
277
+ return self._from_sources(scores)
278
+
279
+ def _annotate_allele_rows(
280
+ self, annotatable: VCFAllele,
281
+ ) -> AnnotatedValues:
282
+ """Fold the rows of one allele on a ``many`` resource.
283
+
284
+ Each score attribute by its own aggregator, resolved as on the
285
+ region fold; the virtual ``allele`` attribute takes the distinct
286
+ keys of the rows. ``None`` under every attribute when no row
287
+ holds the allele; rows the filter rejects in full are an empty
288
+ selection, which each aggregator answers for.
289
+ """
290
+ aggregate = self.allele_score.get_allele_scores_for_allele_agg(
291
+ annotatable.chrom, annotatable.position,
292
+ annotatable.reference, annotatable.alternative,
293
+ queries=self._region_queries,
294
+ allele_keys=self._allele_keys_request(),
295
+ score_filter=self.allele_filter,
296
+ )
297
+ return self._from_aggregate(aggregate)
298
+
299
+ def _allele_keys_request(self) -> list[str] | None:
300
+ """What a folding read is asked for keys: ``None`` builds none."""
301
+ return (
302
+ self.attrs_to_include
303
+ if self.allele_attribute is not None else None)
304
+
305
+ def _from_aggregate(
306
+ self, aggregate: AlleleAggregate | None,
307
+ ) -> AnnotatedValues:
308
+ """Answer a folding read's aggregate, keyed by attribute name.
309
+
310
+ ``None`` is absent data -- no record was there -- and answers
311
+ ``None`` for every attribute. An aggregate whose fold saw nothing is
312
+ different: records were there and the filter rejected them all,
313
+ so each aggregator has answered for an empty selection and the
314
+ keys are empty. The values are paired back over the attributes
315
+ that built the queries, the ``allele`` attribute taking the keys.
316
+ """
317
+ if aggregate is None:
318
+ return self._empty_result()
319
+ return self._pair_aggregated(
320
+ aggregate.values, len(self._region_queries),
321
+ resource_id=self.allele_score.resource_id,
322
+ reduced=lambda attr: attr is not self.allele_attribute,
323
+ otherwise=lambda _attr: list(aggregate.allele_keys or ()))
324
+
325
+ def _annotate_region(
326
+ self, annotatable: Annotatable,
327
+ ) -> AnnotatedValues:
328
+ """Answer the region already reduced, keyed by attribute name.
329
+
330
+ The SCORE reduces (gain#1163): one value per query and, when the
331
+ virtual ``allele`` attribute is configured, the distinct allele
332
+ keys, off a single walk that never materialises the records.
333
+ That removes the per-record list this path used to hold beside
334
+ the aggregators (gain#834); what an aggregator itself keeps --
335
+ ``list``, the ``str`` default, keeps every value -- is the
336
+ aggregator's property and stays.
337
+ """
338
+ aggregate = self.allele_score.get_allele_scores_in_region_agg(
339
+ annotatable.chrom, annotatable.position, annotatable.pos_end,
340
+ queries=self._region_queries,
341
+ allele_keys=self._allele_keys_request(),
342
+ score_filter=self.allele_filter,
343
+ )
344
+ return self._from_aggregate(aggregate)
345
+
346
+ def _matched_exactly(self, allele: VCFAllele) -> bool:
347
+ """Tell whether the resource keys ``allele`` as a line of its own.
348
+
349
+ Every allele on an ``alleles`` resource; only a substitution on a
350
+ ``substitutions`` one. The score's reads are mode-blind, so this
351
+ is the one place the resource's mode is honoured.
352
+ """
353
+ if self.allele_score.alleles_mode():
354
+ return True
355
+ return allele.type == Annotatable.Type.SUBSTITUTION
356
+
357
+ def _do_annotate(
358
+ self, annotatable: Annotatable,
359
+ context: dict[str, Any], # ruff: ignore[unused-method-argument]
360
+ ) -> AnnotatedValues:
361
+ """Route the annotatable to the exact match or the region fold.
362
+
363
+ A ``VCFAllele`` in ``allele`` mode goes where the resource's
364
+ ``allele_score_mode`` says it can be matched (gain#1748): every
365
+ allele on an ``alleles`` resource, only a substitution on a
366
+ ``substitutions`` one. The rest -- and a ``VCFAllele`` in
367
+ ``region`` mode, an explicit override -- is region-folded.
368
+ Every fold is subject to ``region_length_cutoff``; the exact
369
+ match is not a fold and never is.
370
+ """
371
+ if not self.allele_score.has_chromosome(annotatable.chromosome):
372
+ return self._empty_result()
373
+
374
+ if (
375
+ isinstance(annotatable, VCFAllele)
376
+ and self.mode != "region"
377
+ and self._matched_exactly(annotatable)
378
+ ):
379
+ return self._annotate_allele(annotatable)
380
+
381
+ too_long = self._beyond_region_length_cutoff(annotatable)
382
+ if too_long is not None:
383
+ return too_long
384
+ return self._annotate_region(annotatable)