dae.query_variants.sql.schema2 package
Subpackages
- dae.query_variants.sql.schema2.tests package
- Submodules
- dae.query_variants.sql.schema2.tests.conftest module
- dae.query_variants.sql.schema2.tests.test_query_builders module
- dae.query_variants.sql.schema2.tests.test_sql_query_builder module
- dae.query_variants.sql.schema2.tests.test_sql_query_builder_duckdb module
- dae.query_variants.sql.schema2.tests.test_sql_query_builder_duckdb_with_partitions module
- Module contents
Submodules
dae.query_variants.sql.schema2.base_query_builder module
- class dae.query_variants.sql.schema2.base_query_builder.BaseQueryBuilder(dialect: Dialect, db: str | None, family_variant_table: str | None, summary_allele_table: str, pedigree_table: str, family_variant_schema: dict[str, str] | None, summary_allele_schema: dict[str, str], partition_config: dict[str, Any] | None, pedigree_schema: dict[str, str], families: FamiliesData, gene_models: GeneModels | None = None, reference_genome: ReferenceGenome | None = None)[source]
Bases:
ABC
Class that abstracts away the process of building a query.
- GENE_REGIONS_HEURISTIC_CUTOFF = 20
- GENE_REGIONS_HEURISTIC_EXTEND = 20000
- MAX_CHILD_NUMBER = 9999
- QUOTE = "'"
- WHERE = '\n WHERE\n {where}\n '
- build_query(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, family_ids: Iterable[str] | None = None, person_ids: Iterable[str] | None = None, inheritance: str | list[str] | None = None, roles: str | None = None, sexes: str | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, pedigree_fields: tuple | None = None) str [source]
Build an SQL query in the correct order.
dae.query_variants.sql.schema2.base_variants module
- class dae.query_variants.sql.schema2.base_variants.SqlSchema2Variants(dialect: Dialect, db: str | None, family_variant_table: str | None, summary_allele_table: str | None, pedigree_table: str, meta_table: str, gene_models: GeneModels | None = None)[source]
Bases:
QueryVariantsBase
Base class for Schema2 SQL like variants’ query interface.
- RUNNER_CLASS: type[QueryRunner]
- build_family_variants_query_runner(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, family_ids: list[str] | None = None, person_ids: list[str] | None = None, inheritance: list[str] | None = None, roles: str | None = None, sexes: str | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, study_filters: list[str] | None = None, pedigree_fields: tuple | None = None, **kwargs: Any) QueryRunner [source]
Build a query selecting the appropriate family variants.
- static build_person_set_collection_query(person_set_collection: PersonSetCollection, person_set_collection_query: tuple[str, set[str]]) tuple | tuple[list[str], list[str]] | None [source]
No idea what it does. If you know please edit.
- build_summary_variants_query_runner(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, **kwargs: Any) QueryRunner [source]
Build a query selecting the appropriate summary variants.
- query_summary_variants(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, **kwargs: Any) Generator[SummaryVariant, None, None] [source]
Query summary variants.
- query_variants(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, family_ids: list[str] | None = None, person_ids: list[str] | None = None, inheritance: list[str] | None = None, roles: str | None = None, sexes: str | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, pedigree_fields: tuple | None = None, **kwargs: Any) Generator[FamilyVariant, None, None] [source]
Query family variants.
dae.query_variants.sql.schema2.family_builder module
- class dae.query_variants.sql.schema2.family_builder.FamilyQueryBuilder(dialect: Dialect, db: str, family_variant_table: str, summary_allele_table: str, pedigree_table: str, family_variant_schema: dict[str, str], summary_allele_schema: dict[str, str], table_properties: dict | None, pedigree_schema: dict[str, str], families: FamiliesData, gene_models: GeneModels | None = None, do_join_pedigree: bool = False, do_join_allele_in_members: bool = False)[source]
Bases:
BaseQueryBuilder
Build queries related to family variants.
dae.query_variants.sql.schema2.sql_query_builder module
- class dae.query_variants.sql.schema2.sql_query_builder.Db2Layout(db: str | None, study: str, pedigree: str, summary: str | None, family: str | None, meta: str)[source]
Bases:
object
Genotype data layout in the database.
- db: str | None
- family: str | None
- meta: str
- pedigree: str
- study: str
- summary: str | None
- class dae.query_variants.sql.schema2.sql_query_builder.QueryBuilderBase(schema: Schema, families: FamiliesData, partition_descriptor: PartitionDescriptor | None, gene_models: GeneModels, reference_genome: ReferenceGenome)[source]
Bases:
object
Base class for building SQL queries.
- GENE_REGIONS_HEURISTIC_CUTOFF = 20
- GENE_REGIONS_HEURISTIC_EXTEND = 20000
- REGION_BINS_HEURISTIC_CUTOFF = 20
- build_gene_regions(genes: list[str], regions: list[Region] | None) list[Region] | None [source]
Build a list of regions based on genes.
- static build_inheritance_query(inheritance_query: Sequence[str], attr: str) str [source]
Construct an inheritance query.
- static build_schema(summary_schema: dict[str, str], family_schema: dict[str, str], pedigree_schema: dict[str, str]) Schema [source]
- static build_variant_types_query(variant_types_query: str, attr: str) str [source]
Build a variant types query.
- calc_batched_heuristics(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, inheritance: Sequence[str] | None = None, roles: str | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, family_ids: Iterable[str] | None = None, person_ids: Iterable[str] | None = None) list[QueryHeuristics] [source]
Calculate heuristics baches for a query.
- calc_coding_bins(effect_types: Sequence[str] | None) list[str] [source]
Calculate applicable coding bins for a query.
- calc_family_bins(family_ids: Iterable[str] | None, person_ids: Iterable[str] | None) list[str] [source]
Calculate family bins for a query.
- calc_frequency_bins(*, inheritance: Sequence[str] | None = None, roles: str | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None) list[str] [source]
Calculate applicable frequency bins for a query.
- calc_heuristics(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, inheritance: Sequence[str] | None = None, roles: str | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, family_ids: Iterable[str] | None = None, person_ids: Iterable[str] | None = None) QueryHeuristics [source]
Calculate heuristic bins for a query.
- calc_region_bins(regions: list[Region] | None) list[str] [source]
Calculate applicable region bins for a query.
- static check_inheritance_denovo_only(inheritance_query: Sequence[str]) bool [source]
Check if inheritance query is de novo only.
- static check_inheritance_query_value(inheritance_query: Sequence[str], value: int) bool [source]
Check if value satisfies a given inheritance query.
- static check_roles_denovo_only(roles_query: str) bool [source]
Check if roles query is de novo only.
- static check_roles_query_value(roles_query: str, value: int) bool [source]
Check if value satisfies a given roles query.
- class dae.query_variants.sql.schema2.sql_query_builder.QueryHeuristics(region_bins: list[str], coding_bins: list[str], frequency_bins: list[str], family_bins: list[str])[source]
Bases:
object
Heuristics for a query.
- coding_bins: list[str]
- family_bins: list[str]
- frequency_bins: list[str]
- region_bins: list[str]
- class dae.query_variants.sql.schema2.sql_query_builder.SqlQueryBuilder(db_layout: Db2Layout, *, schema: Schema, partition_descriptor: PartitionDescriptor | None, families: FamiliesData, gene_models: GeneModels, reference_genome: ReferenceGenome)[source]
Bases:
QueryBuilderBase
Build SQL queries using sqlglot.
- apply_family_heuristics(query: Select, heuristics: QueryHeuristics | None) Select [source]
Apply heuristics to the family query.
- apply_summary_heuristics(query: Select, heuristics: QueryHeuristics | None, table: str = 'sa') Select [source]
Apply heuristics to the summary query.
- static build(db_layout: Db2Layout, *, pedigree_schema: dict[str, str], summary_schema: dict[str, str], family_schema: dict[str, str], partition_descriptor: PartitionDescriptor | None, families: FamiliesData, gene_models: GeneModels, reference_genome: ReferenceGenome) SqlQueryBuilder [source]
Return a new instance of the builder.
- build_family_variants_query(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, family_ids: Sequence[str] | None = None, person_ids: Sequence[str] | None = None, inheritance: Sequence[str] | None = None, roles: str | None = None, sexes: str | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None, **_kwargs: Any) list[str] [source]
Build a query for family variants.
- build_summary_variants_query(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None, limit: int | None = None) list[str] [source]
Build a query for summary variants.
- static coding_bins(table: str, coding_bins: list[str]) Condition [source]
Create coding bins condition.
- static family_bins(table: str, family_bins: list[str]) Condition [source]
Create family bins condition.
- family_query(family_ids: Sequence[str] | None = None, person_ids: Sequence[str] | None = None, inheritance: str | Sequence[str] | None = None, roles: str | None = None, sexes: str | None = None) Select [source]
Build a family subclause query.
- static frequency(real_attrs: list[tuple[str, tuple[float | None, float | None]]]) Condition [source]
Build frequencies filter where condition.
- static frequency_bins(table: str, frequency_bins: list[str]) Condition [source]
Create frequency bins condition.
- static inheritance(inheritance_query: str | Sequence[str]) Condition [source]
Build inheritance filter.
- static real_attr(real_attrs: list[tuple[str, tuple[float | None, float | None]]]) Condition [source]
Build real attributes filter where condition.
- static region_bins(table: str, region_bins: list[str]) Condition [source]
Create region bins condition.
- summary_query(*, regions: list[Region] | None = None, genes: list[str] | None = None, effect_types: list[str] | None = None, variant_type: str | None = None, real_attr_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, ultra_rare: bool | None = None, frequency_filter: list[tuple[str, tuple[float | None, float | None]]] | None = None, return_reference: bool | None = None, return_unknown: bool | None = None) Select [source]
Build a summary variant query.
dae.query_variants.sql.schema2.summary_builder module
- class dae.query_variants.sql.schema2.summary_builder.SummaryQueryBuilder(dialect: Dialect, db: str | None, family_variant_table: str | None, summary_allele_table: str, pedigree_table: str, family_variant_schema: dict[str, str], summary_allele_schema: dict[str, str], table_properties: dict | None, pedigree_schema: dict[str, str], families: FamiliesData, gene_models: GeneModels | None = None)[source]
Bases:
BaseQueryBuilder
Build queries related to summary variants.