diff --git a/src/seqvars/query/interpreter/regions_allowlist.rs b/src/seqvars/query/interpreter/regions_allowlist.rs index 0fcd4965..9fff9378 100644 --- a/src/seqvars/query/interpreter/regions_allowlist.rs +++ b/src/seqvars/query/interpreter/regions_allowlist.rs @@ -2,7 +2,7 @@ use crate::seqvars::query::schema::{CaseQuery, GenomicRegion, Range, SequenceVar /// Determine whether the `SequenceVariant` passes the regions allowlist filter. pub fn passes(query: &CaseQuery, seqvar: &SequenceVariant) -> bool { - if let Some(region_allowlist) = &query.genomic_regions { + if let Some(region_allowlist) = &query.locus.genomic_regions { if region_allowlist.is_empty() { true } else { diff --git a/src/seqvars/query/mod.rs b/src/seqvars/query/mod.rs index b4b6e2bf..774286d0 100644 --- a/src/seqvars/query/mod.rs +++ b/src/seqvars/query/mod.rs @@ -520,7 +520,7 @@ pub async fn run(args_common: &crate::common::Args, args: &Args) -> Result<(), a trace_rss_now(); tracing::info!("Translating gene allow list..."); - let hgnc_allowlist = if let Some(gene_allowlist) = &query.gene_allowlist { + let hgnc_allowlist = if let Some(gene_allowlist) = &query.locus.gene_allowlist { if gene_allowlist.is_empty() { None } else { diff --git a/src/seqvars/query/schema.rs b/src/seqvars/query/schema.rs index 298cbac4..32a9dedd 100644 --- a/src/seqvars/query/schema.rs +++ b/src/seqvars/query/schema.rs @@ -237,6 +237,38 @@ pub struct PopulationFrequencyOptions { pub helixmtdb: HelixMtDbOptions, } +serde_with::with_prefix!(prefix_var_type "var_type_"); +#[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug, Clone)] +#[serde(default)] +pub struct VariantTypeOptions { + /// Whether to include SNVs. + pub snv: bool, + /// Whether to include indels. + pub indel: bool, + /// Whether to include MNVs. + pub mnv: bool, +} + +impl Default for VariantTypeOptions { + fn default() -> Self { + VariantTypeOptions { + snv: true, + indel: true, + mnv: true, + } + } +} + +#[derive(serde::Serialize, serde::Deserialize, Default, PartialEq, Debug, Clone)] +#[serde(default)] +pub struct LocusRelatedOptions { + /// List of HGNC symbols, HGNC:s, ENSGs, or NCBI Gene IDs to restrict + /// the resulting variants to. + pub gene_allowlist: Option>, + /// List of genomic regions to limit restrict the resulting variants to. + pub genomic_regions: Option>, +} + /// Data structure with a single query. #[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug, Clone)] #[serde(default)] @@ -257,25 +289,15 @@ pub struct CaseQuery { /// Maximal distance to next exon, if any. pub max_exon_dist: Option, - /// TODO v move to varianttyperelated - - /// Whether to include SNVs. - pub var_type_snv: bool, - /// Whether to include indels. - pub var_type_indel: bool, - /// Whether to include MNVs. - pub var_type_mnv: bool, - - /// TODO v Move to locusRelated + /// TODO: comment + #[serde(flatten, with = "prefix_var_type")] + pub var_type: VariantTypeOptions, - /// List of HGNC symbols, HGNC:s, ENSGs, or NCBI Gene IDs to restrict - /// the resulting variants to. - pub gene_allowlist: Option>, - /// List of genomic regions to limit restrict the resulting variants to. - pub genomic_regions: Option>, - - /// TODO: wanted schema is defined in issue, emily reading comprehension 10/10 + /// TODO comment + #[serde(flatten)] + pub locus: LocusRelatedOptions, + // TODO v moving this into ClinVarOptions without making things meh seems to be annoying /// Wether to require ClinVar membership. pub require_in_clinvar: bool, /// ClinVar related filter options. @@ -286,7 +308,6 @@ pub struct CaseQuery { #[serde(flatten)] pub population_freqeuecy: PopulationFrequencyOptions, - /// Inhouse related filter options. TODO BETTER COMMENT #[serde(flatten, with = "prefix_inhouse")] pub inhouse: InhouseFrequencyOptions, @@ -315,12 +336,9 @@ impl Default for CaseQuery { genotype: Default::default(), transcripts_coding: true, transcripts_noncoding: true, - var_type_snv: true, - var_type_indel: true, - var_type_mnv: true, + var_type: Default::default(), max_exon_dist: Default::default(), - gene_allowlist: Default::default(), - genomic_regions: Default::default(), + locus: Default::default(), require_in_clinvar: Default::default(), clinvar: Default::default(), inhouse: Default::default(),