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.
- gain_core-2026.10.2/.gitignore +113 -0
- gain_core-2026.10.2/PKG-INFO +51 -0
- gain_core-2026.10.2/README.md +6 -0
- gain_core-2026.10.2/gain/__init__.py +14 -0
- gain_core-2026.10.2/gain/_version.py +24 -0
- gain_core-2026.10.2/gain/annotation/TODO_annotation_documentation.md +38 -0
- gain_core-2026.10.2/gain/annotation/__init__.py +0 -0
- gain_core-2026.10.2/gain/annotation/allele_score_annotator.py +384 -0
- gain_core-2026.10.2/gain/annotation/allele_scores.md +167 -0
- gain_core-2026.10.2/gain/annotation/annotatable.py +373 -0
- gain_core-2026.10.2/gain/annotation/annotate_doc.py +66 -0
- gain_core-2026.10.2/gain/annotation/annotate_tabular.py +948 -0
- gain_core-2026.10.2/gain/annotation/annotate_utils.py +385 -0
- gain_core-2026.10.2/gain/annotation/annotate_vcf.py +794 -0
- gain_core-2026.10.2/gain/annotation/annotation_config.py +1138 -0
- gain_core-2026.10.2/gain/annotation/annotation_factory.py +324 -0
- gain_core-2026.10.2/gain/annotation/annotation_genomic_context_cli.py +157 -0
- gain_core-2026.10.2/gain/annotation/annotation_pipeline.py +878 -0
- gain_core-2026.10.2/gain/annotation/annotator_base.py +499 -0
- gain_core-2026.10.2/gain/annotation/chrom_mapping_annotator.py +79 -0
- gain_core-2026.10.2/gain/annotation/debug_annotator.py +37 -0
- gain_core-2026.10.2/gain/annotation/docker_annotator.py +53 -0
- gain_core-2026.10.2/gain/annotation/effect_annotator.py +339 -0
- gain_core-2026.10.2/gain/annotation/fragment_score_annotator.py +291 -0
- gain_core-2026.10.2/gain/annotation/gene_score_annotator.py +148 -0
- gain_core-2026.10.2/gain/annotation/gene_set_annotator.py +170 -0
- gain_core-2026.10.2/gain/annotation/genomic_score_annotator_base.py +244 -0
- gain_core-2026.10.2/gain/annotation/liftover_annotator.py +536 -0
- gain_core-2026.10.2/gain/annotation/normalize_allele_annotator.py +86 -0
- gain_core-2026.10.2/gain/annotation/pipeline_doc.py +180 -0
- gain_core-2026.10.2/gain/annotation/position_score_annotator.py +186 -0
- gain_core-2026.10.2/gain/annotation/prepare_tabular.py +736 -0
- gain_core-2026.10.2/gain/annotation/processing_pipeline.py +207 -0
- gain_core-2026.10.2/gain/annotation/record_to_annotatable.py +277 -0
- gain_core-2026.10.2/gain/annotation/simple_effect_annotator.py +319 -0
- gain_core-2026.10.2/gain/annotation/utils.py +141 -0
- gain_core-2026.10.2/gain/annotation/value_transform_eval.py +375 -0
- gain_core-2026.10.2/gain/binning/__init__.py +1 -0
- gain_core-2026.10.2/gain/binning/binners.py +663 -0
- gain_core-2026.10.2/gain/binning/cli.py +559 -0
- gain_core-2026.10.2/gain/binning/fragment_binner.py +1496 -0
- gain_core-2026.10.2/gain/binning/fragment_def.py +52 -0
- gain_core-2026.10.2/gain/binning/fragment_folds.py +393 -0
- gain_core-2026.10.2/gain/binning/h5_reader.py +175 -0
- gain_core-2026.10.2/gain/binning/position_fold.py +375 -0
- gain_core-2026.10.2/gain/binning/run_definition.py +253 -0
- gain_core-2026.10.2/gain/binning/view_cli.py +303 -0
- gain_core-2026.10.2/gain/dask/__init__.py +2 -0
- gain_core-2026.10.2/gain/dask/config.py +265 -0
- gain_core-2026.10.2/gain/dask/named_cluster.py +281 -0
- gain_core-2026.10.2/gain/dask/named_cluster.yaml +95 -0
- gain_core-2026.10.2/gain/effect_annotation/README.md +68 -0
- gain_core-2026.10.2/gain/effect_annotation/__init__.py +0 -0
- gain_core-2026.10.2/gain/effect_annotation/annotation_effects.py +116 -0
- gain_core-2026.10.2/gain/effect_annotation/annotation_request.py +561 -0
- gain_core-2026.10.2/gain/effect_annotation/annotator.py +279 -0
- gain_core-2026.10.2/gain/effect_annotation/cli.py +451 -0
- gain_core-2026.10.2/gain/effect_annotation/effect.py +888 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/__init__.py +0 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/coding.py +32 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/effect_checker.py +13 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/frame_shift.py +107 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/intron.py +57 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/promoter.py +82 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/protein_change.py +45 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/splice_site.py +56 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/start_loss.py +31 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/stop_loss.py +45 -0
- gain_core-2026.10.2/gain/effect_annotation/effect_checkers/utr.py +122 -0
- gain_core-2026.10.2/gain/effect_annotation/gene_codes.py +35 -0
- gain_core-2026.10.2/gain/effect_annotation/variant.py +152 -0
- gain_core-2026.10.2/gain/gene_scores/__init__.py +0 -0
- gain_core-2026.10.2/gain/gene_scores/gene_scores.py +650 -0
- gain_core-2026.10.2/gain/gene_scores/implementations/__init__.py +0 -0
- gain_core-2026.10.2/gain/gene_scores/implementations/gene_scores_impl.py +170 -0
- gain_core-2026.10.2/gain/gene_sets/__init__.py +0 -0
- gain_core-2026.10.2/gain/gene_sets/gene_set.py +607 -0
- gain_core-2026.10.2/gain/gene_sets/gene_term.py +320 -0
- gain_core-2026.10.2/gain/gene_sets/implementations/__init__.py +0 -0
- gain_core-2026.10.2/gain/gene_sets/implementations/gene_sets_impl.py +328 -0
- gain_core-2026.10.2/gain/genomic_resources/__init__.py +100 -0
- gain_core-2026.10.2/gain/genomic_resources/aggregators.py +1027 -0
- gain_core-2026.10.2/gain/genomic_resources/allele_classification.py +103 -0
- gain_core-2026.10.2/gain/genomic_resources/ann_data_10x.py +600 -0
- gain_core-2026.10.2/gain/genomic_resources/ann_data_resource.py +405 -0
- gain_core-2026.10.2/gain/genomic_resources/bigwig_scores.py +228 -0
- gain_core-2026.10.2/gain/genomic_resources/cached_repository.py +1121 -0
- gain_core-2026.10.2/gain/genomic_resources/cli.py +1769 -0
- gain_core-2026.10.2/gain/genomic_resources/cli_cache_repo.py +84 -0
- gain_core-2026.10.2/gain/genomic_resources/cli_dvc.py +103 -0
- gain_core-2026.10.2/gain/genomic_resources/cli_errors.py +70 -0
- gain_core-2026.10.2/gain/genomic_resources/cli_list.py +139 -0
- gain_core-2026.10.2/gain/genomic_resources/data_frame_resource.py +161 -0
- gain_core-2026.10.2/gain/genomic_resources/draw_score_histograms.py +207 -0
- gain_core-2026.10.2/gain/genomic_resources/dvc.py +150 -0
- gain_core-2026.10.2/gain/genomic_resources/fsspec_protocol.py +3531 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/__init__.py +21 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/default_attributes.py +83 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/gene_models.py +496 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/gene_models_factory.py +147 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/parsers.py +1346 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/record_cells.py +315 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/serialization.py +541 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/to_gpf_gene_models_format.py +63 -0
- gain_core-2026.10.2/gain/genomic_resources/gene_models/transcript_models.py +791 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_context.py +340 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_context_base.py +457 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_context_cli.py +172 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/__init__.py +886 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/index_columns.py +103 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/line.py +368 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/record.py +212 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table.py +966 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_bigwig.py +469 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_inmemory.py +336 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_tabix.py +1027 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/table_vcf.py +330 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_position_table/utils.py +162 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/__init__.py +128 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/aggregation.py +434 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/allele.py +1641 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/base.py +1598 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/batch_budget.py +32 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/builders.py +298 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/chrom_lengths.py +486 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/fragment.py +1134 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/position.py +978 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/records.py +205 -0
- gain_core-2026.10.2/gain/genomic_resources/genomic_scores/value_extraction.py +209 -0
- gain_core-2026.10.2/gain/genomic_resources/group_repository.py +296 -0
- gain_core-2026.10.2/gain/genomic_resources/histogram.py +2063 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/__init__.py +0 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/ann_data_resource_impl.py +230 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/annotation_pipeline_impl.py +115 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/basic_resource_impl.py +73 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/data_frame_resource_impl.py +144 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/gene_models_impl.py +190 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/__init__.py +49 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/allele.py +73 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/base.py +615 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/builders.py +43 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/fragment.py +69 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/position.py +114 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/genomic_scores_impl/scan.py +1254 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/liftover_chain_impl.py +93 -0
- gain_core-2026.10.2/gain/genomic_resources/implementations/reference_genome_impl.py +617 -0
- gain_core-2026.10.2/gain/genomic_resources/index_search_grammar.ne +36 -0
- gain_core-2026.10.2/gain/genomic_resources/liftover_chain.py +301 -0
- gain_core-2026.10.2/gain/genomic_resources/memo.py +88 -0
- gain_core-2026.10.2/gain/genomic_resources/reference_genome.py +669 -0
- gain_core-2026.10.2/gain/genomic_resources/repository.py +3514 -0
- gain_core-2026.10.2/gain/genomic_resources/repository_factory.py +948 -0
- gain_core-2026.10.2/gain/genomic_resources/resource_errors.py +273 -0
- gain_core-2026.10.2/gain/genomic_resources/resource_implementation.py +951 -0
- gain_core-2026.10.2/gain/genomic_resources/resource_query.py +313 -0
- gain_core-2026.10.2/gain/genomic_resources/resource_types.py +479 -0
- gain_core-2026.10.2/gain/genomic_resources/score_def.py +966 -0
- gain_core-2026.10.2/gain/genomic_resources/score_filter.py +388 -0
- gain_core-2026.10.2/gain/genomic_resources/score_implementation.py +270 -0
- gain_core-2026.10.2/gain/genomic_resources/score_resource.py +488 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/__init__.py +0 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/alleles.py +1445 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/base_statistic.py +286 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/chart_style.py +17 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/coverage.py +1115 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/exact_lengths.py +650 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/fragments.py +408 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/length_histogram.py +128 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/min_max.py +165 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/moments.py +169 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/percentages.py +88 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/record_validation.py +374 -0
- gain_core-2026.10.2/gain/genomic_resources/statistics/region_fold.py +60 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/__init__.py +861 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/ann_data_builder.py +568 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/annotation_pipeline_builder.py +148 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/builders.py +2304 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/data_frame_builder.py +260 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/extra_files.py +79 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/faulty_filesystem.py +426 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/gene_models_builder.py +614 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/gene_set_collection_builder.py +173 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/group_builder.py +164 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/info_page_fixtures.py +259 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/liftover_chain_builder.py +113 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/resource_meta.py +190 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/score_specs.py +278 -0
- gain_core-2026.10.2/gain/genomic_resources/testing/statistics.py +138 -0
- gain_core-2026.10.2/gain/genomic_resources/utils.py +135 -0
- gain_core-2026.10.2/gain/genomic_resources/variant_utils.py +96 -0
- gain_core-2026.10.2/gain/genomic_resources/vcf_scores.py +752 -0
- gain_core-2026.10.2/gain/grr/__init__.py +127 -0
- gain_core-2026.10.2/gain/logging.py +68 -0
- gain_core-2026.10.2/gain/py.typed +0 -0
- gain_core-2026.10.2/gain/task_graph/__init__.py +3 -0
- gain_core-2026.10.2/gain/task_graph/base_executor.py +367 -0
- gain_core-2026.10.2/gain/task_graph/cache.py +369 -0
- gain_core-2026.10.2/gain/task_graph/cli_tools.py +497 -0
- gain_core-2026.10.2/gain/task_graph/dask_executor.py +479 -0
- gain_core-2026.10.2/gain/task_graph/dask_run_state.py +490 -0
- gain_core-2026.10.2/gain/task_graph/demo_graphs_cli.py +197 -0
- gain_core-2026.10.2/gain/task_graph/executor.py +95 -0
- gain_core-2026.10.2/gain/task_graph/graph.py +794 -0
- gain_core-2026.10.2/gain/task_graph/logging.py +100 -0
- gain_core-2026.10.2/gain/task_graph/process_pool_executor.py +166 -0
- gain_core-2026.10.2/gain/task_graph/sequential_executor.py +52 -0
- gain_core-2026.10.2/gain/task_graph/work_dir.py +120 -0
- gain_core-2026.10.2/gain/templates/__init__.py +197 -0
- gain_core-2026.10.2/gain/templates/breadcrumb.py +72 -0
- gain_core-2026.10.2/gain/templates/markdown_support.py +159 -0
- gain_core-2026.10.2/gain/templates/static/fonts/LICENSE-Material-Symbols.txt +177 -0
- gain_core-2026.10.2/gain/templates/static/fonts/LICENSE-Roboto.txt +93 -0
- gain_core-2026.10.2/gain/templates/static/fonts/README.md +102 -0
- gain_core-2026.10.2/gain/templates/static/fonts/material-symbols-outlined-v371.woff2 +0 -0
- gain_core-2026.10.2/gain/templates/static/fonts/roboto-v51-latin.woff2 +0 -0
- gain_core-2026.10.2/gain/templates/static/sqlite-wasm/LICENSE +177 -0
- gain_core-2026.10.2/gain/templates/static/sqlite-wasm/README.md +57 -0
- gain_core-2026.10.2/gain/templates/static/sqlite-wasm/index.mjs +10650 -0
- gain_core-2026.10.2/gain/templates/static/sqlite-wasm/sqlite3.wasm +0 -0
- gain_core-2026.10.2/gain/templates/static/sqlite-wasm/version.txt +1 -0
- gain_core-2026.10.2/gain/templates/static_assets.py +147 -0
- gain_core-2026.10.2/gain/templates/template_files/.keep +0 -0
- gain_core-2026.10.2/gain/templates/template_files/allele_score.jinja +222 -0
- gain_core-2026.10.2/gain/templates/template_files/ann_data.jinja +38 -0
- gain_core-2026.10.2/gain/templates/template_files/annotate_doc_pipeline_template.jinja +261 -0
- gain_core-2026.10.2/gain/templates/template_files/annotation_pipeline.jinja +5 -0
- gain_core-2026.10.2/gain/templates/template_files/base_implementation.jinja +4 -0
- gain_core-2026.10.2/gain/templates/template_files/base_implementation_styles.jinja +0 -0
- gain_core-2026.10.2/gain/templates/template_files/base_styles.jinja +174 -0
- gain_core-2026.10.2/gain/templates/template_files/basic.jinja +3 -0
- gain_core-2026.10.2/gain/templates/template_files/breadcrumb.jinja +28 -0
- gain_core-2026.10.2/gain/templates/template_files/breadcrumb_styles.jinja +42 -0
- gain_core-2026.10.2/gain/templates/template_files/content_styles.jinja +106 -0
- gain_core-2026.10.2/gain/templates/template_files/copy_button.jinja +31 -0
- gain_core-2026.10.2/gain/templates/template_files/copy_button_styles.jinja +13 -0
- gain_core-2026.10.2/gain/templates/template_files/data_frame.jinja +13 -0
- gain_core-2026.10.2/gain/templates/template_files/fragment_score.jinja +57 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_models.jinja +40 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_models_styles.jinja +0 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_score.jinja +99 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_score_help.jinja +16 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_score_styles.jinja +3 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_set_collection.jinja +78 -0
- gain_core-2026.10.2/gain/templates/template_files/gene_set_collection_styles.jinja +9 -0
- gain_core-2026.10.2/gain/templates/template_files/genomic_score.jinja +130 -0
- gain_core-2026.10.2/gain/templates/template_files/genomic_score_help.jinja +50 -0
- gain_core-2026.10.2/gain/templates/template_files/genomic_score_styles.jinja +3 -0
- gain_core-2026.10.2/gain/templates/template_files/grr_about.jinja +79 -0
- gain_core-2026.10.2/gain/templates/template_files/grr_index.jinja +548 -0
- gain_core-2026.10.2/gain/templates/template_files/grr_scripts.jinja +1643 -0
- gain_core-2026.10.2/gain/templates/template_files/icon_font.jinja +47 -0
- gain_core-2026.10.2/gain/templates/template_files/length_statistics.jinja +82 -0
- gain_core-2026.10.2/gain/templates/template_files/liftover_chain.jinja +15 -0
- gain_core-2026.10.2/gain/templates/template_files/moments_summary.jinja +19 -0
- gain_core-2026.10.2/gain/templates/template_files/position_score.jinja +150 -0
- gain_core-2026.10.2/gain/templates/template_files/reference_genome.jinja +75 -0
- gain_core-2026.10.2/gain/templates/template_files/reference_genome_styles.jinja +3 -0
- gain_core-2026.10.2/gain/templates/template_files/resource_template.jinja +243 -0
- gain_core-2026.10.2/gain/templates/template_files/roboto_font.jinja +31 -0
- gain_core-2026.10.2/gain/templates/template_files/score_histogram.jinja +12 -0
- gain_core-2026.10.2/gain/templates/template_files/sortable_table.jinja +210 -0
- gain_core-2026.10.2/gain/templates/template_files/statistics_template.jinja +54 -0
- gain_core-2026.10.2/gain/testing/__init__.py +0 -0
- gain_core-2026.10.2/gain/testing/acgt_import.py +37 -0
- gain_core-2026.10.2/gain/testing/alla_import.py +41 -0
- gain_core-2026.10.2/gain/testing/foobar_import.py +39 -0
- gain_core-2026.10.2/gain/testing/t4c8_import.py +146 -0
- gain_core-2026.10.2/gain/utils/__init__.py +0 -0
- gain_core-2026.10.2/gain/utils/chromosome_order.py +68 -0
- gain_core-2026.10.2/gain/utils/cnv_utils.py +29 -0
- gain_core-2026.10.2/gain/utils/dae_utils.py +74 -0
- gain_core-2026.10.2/gain/utils/debug_closing.py +65 -0
- gain_core-2026.10.2/gain/utils/dict_utils.py +45 -0
- gain_core-2026.10.2/gain/utils/fs_utils.py +243 -0
- gain_core-2026.10.2/gain/utils/helpers.py +64 -0
- gain_core-2026.10.2/gain/utils/log_levels.py +75 -0
- gain_core-2026.10.2/gain/utils/log_safety.py +44 -0
- gain_core-2026.10.2/gain/utils/processing_pipeline.py +81 -0
- gain_core-2026.10.2/gain/utils/regions.py +645 -0
- gain_core-2026.10.2/gain/utils/resource_id_order.py +49 -0
- gain_core-2026.10.2/gain/utils/stats_collection.py +75 -0
- gain_core-2026.10.2/gain/utils/stringify.py +44 -0
- gain_core-2026.10.2/gain/utils/url_redaction.py +150 -0
- gain_core-2026.10.2/gain/utils/variant_utils.py +113 -0
- gain_core-2026.10.2/gain/utils/verbosity_configuration.py +58 -0
- gain_core-2026.10.2/gain/utils/zulip_logging.py +265 -0
- 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)
|