diff --git a/protos/varfish/v1/seqvars/query.proto b/protos/varfish/v1/seqvars/query.proto index d1715f31..3bf45e8c 100644 --- a/protos/varfish/v1/seqvars/query.proto +++ b/protos/varfish/v1/seqvars/query.proto @@ -93,13 +93,13 @@ message NuclearFrequencySettings { // Whether to enable filtration by 1000 Genomes. bool enabled = 1; // Maximal number of in-house heterozygous carriers - optional int32 heterozygous = 2; + optional int32 max_het = 2; // Maximal number of in-house homozygous carriers - optional int32 homozygous = 3; + optional int32 max_hom = 3; // Maximal number of in-house hemizygous carriers - optional int32 hemizygous = 4; + optional int32 max_hemi = 4; // Maximal allele frequency. - optional float frequency = 5; + optional float max_af = 5; } // Mitochondrial filter options. @@ -107,11 +107,11 @@ message MitochondrialFrequencySettings { // Whether to enable filtration by 1000 Genomes. bool enabled = 1; // Maximal number of heteroplasmic carriers. - optional int32 heteroplasmic = 2; + optional int32 max_het = 2; // Maximal number of homoplasmic carriers. - optional int32 homoplasmic = 3; + optional int32 max_hom = 3; // Maximal allele frequency. - optional float frequency = 4; + optional float max_af = 4; } // Population frequency filter options. diff --git a/src/seqvars/query/interpreter/frequency.rs b/src/seqvars/query/interpreter/frequency.rs index 12680896..8dbe3890 100644 --- a/src/seqvars/query/interpreter/frequency.rs +++ b/src/seqvars/query/interpreter/frequency.rs @@ -10,15 +10,15 @@ pub fn passes(query: &CaseQuery, s: &VariantRecord) -> Result frequency.helixmtdb.frequency.expect("tested before") - || frequency.helixmtdb.heteroplasmic.is_some() + > frequency.helixmtdb.max_af.expect("tested before") + || frequency.helixmtdb.max_het.is_some() && s.population_frequencies.helixmtdb.het - > frequency.helixmtdb.heteroplasmic.expect("tested before") - || frequency.helixmtdb.homoplasmic.is_some() + > frequency.helixmtdb.max_het.expect("tested before") + || frequency.helixmtdb.max_hom.is_some() && s.population_frequencies.helixmtdb.hom - > frequency.helixmtdb.homoplasmic.expect("tested before")) + > frequency.helixmtdb.max_hom.expect("tested before")) { tracing::trace!( "variant {:?} fails HelixMtDb frequency filter {:?}", @@ -28,15 +28,15 @@ pub fn passes(query: &CaseQuery, s: &VariantRecord) -> Result frequency.gnomad_mtdna.frequency.expect("tested before") - || frequency.gnomad_mtdna.heteroplasmic.is_some() + > frequency.gnomad_mtdna.max_af.expect("tested before") + || frequency.gnomad_mtdna.max_het.is_some() && s.population_frequencies.gnomad_mtdna.het - > frequency.gnomad_mtdna.heteroplasmic.expect("tested before") - || frequency.gnomad_mtdna.homoplasmic.is_some() + > frequency.gnomad_mtdna.max_het.expect("tested before") + || frequency.gnomad_mtdna.max_hom.is_some() && s.population_frequencies.gnomad_mtdna.hom - > frequency.gnomad_mtdna.homoplasmic.expect("tested before")) + > frequency.gnomad_mtdna.max_hom.expect("tested before")) { tracing::trace!( "variant {:?} fails gnomAD-MT frequency filter {:?}", @@ -47,18 +47,18 @@ pub fn passes(query: &CaseQuery, s: &VariantRecord) -> Result frequency.gnomad_exomes.frequency.expect("tested before") - || frequency.gnomad_exomes.heterozygous.is_some() + > frequency.gnomad_exomes.max_af.expect("tested before") + || frequency.gnomad_exomes.max_het.is_some() && s.population_frequencies.gnomad_exomes.het - > frequency.gnomad_exomes.heterozygous.expect("tested before") - || frequency.gnomad_exomes.homozygous.is_some() + > frequency.gnomad_exomes.max_het.expect("tested before") + || frequency.gnomad_exomes.max_hom.is_some() && s.population_frequencies.gnomad_exomes.hom - > frequency.gnomad_exomes.homozygous.expect("tested before") - || frequency.gnomad_exomes.hemizygous.is_some() + > frequency.gnomad_exomes.max_hom.expect("tested before") + || frequency.gnomad_exomes.max_hemi.is_some() && s.population_frequencies.gnomad_exomes.hemi - > frequency.gnomad_exomes.hemizygous.expect("tested before")) + > frequency.gnomad_exomes.max_hemi.expect("tested before")) { tracing::trace!( "variant {:?} fails gnomAD-exomes frequency filter {:?}", @@ -68,21 +68,18 @@ pub fn passes(query: &CaseQuery, s: &VariantRecord) -> Result frequency.gnomad_genomes.frequency.expect("tested before") - || frequency.gnomad_genomes.heterozygous.is_some() + > frequency.gnomad_genomes.max_af.expect("tested before") + || frequency.gnomad_genomes.max_het.is_some() && s.population_frequencies.gnomad_genomes.het - > frequency - .gnomad_genomes - .heterozygous - .expect("tested before") - || frequency.gnomad_genomes.homozygous.is_some() + > frequency.gnomad_genomes.max_het.expect("tested before") + || frequency.gnomad_genomes.max_hom.is_some() && s.population_frequencies.gnomad_genomes.hom - > frequency.gnomad_genomes.homozygous.expect("tested before") - || frequency.gnomad_genomes.hemizygous.is_some() + > frequency.gnomad_genomes.max_hom.expect("tested before") + || frequency.gnomad_genomes.max_hemi.is_some() && s.population_frequencies.gnomad_genomes.hemi - > frequency.gnomad_genomes.hemizygous.expect("tested before")) + > frequency.gnomad_genomes.max_hemi.expect("tested before")) { tracing::trace!( "variant {:?} fails gnomAD-genomes frequency filter {:?}", @@ -182,10 +179,10 @@ mod test { frequency: QuerySettingsFrequency { gnomad_exomes: NuclearFrequencySettings { enabled: query_gnomad_exomes_enabled, - frequency: query_gnomad_exomes_frequency, - heterozygous: query_gnomad_exomes_heterozygous, - homozygous: query_gnomad_exomes_homozygous, - hemizygous: query_gnomad_exomes_hemizygous, + max_af: query_gnomad_exomes_frequency, + max_het: query_gnomad_exomes_heterozygous, + max_hom: query_gnomad_exomes_homozygous, + max_hemi: query_gnomad_exomes_hemizygous, }, ..Default::default() }, @@ -313,10 +310,10 @@ mod test { frequency: QuerySettingsFrequency { gnomad_genomes: NuclearFrequencySettings { enabled: query_gnomad_genomes_enabled, - frequency: query_gnomad_genomes_frequency, - heterozygous: query_gnomad_genomes_heterozygous, - homozygous: query_gnomad_genomes_homozygous, - hemizygous: query_gnomad_genomes_hemizygous, + max_af: query_gnomad_genomes_frequency, + max_het: query_gnomad_genomes_heterozygous, + max_hom: query_gnomad_genomes_homozygous, + max_hemi: query_gnomad_genomes_hemizygous, }, ..Default::default() }, @@ -416,18 +413,18 @@ mod test { #[case] seqvar_helix_het: i32, #[case] seqvar_helix_hom: i32, #[case] query_helixmtdb_enabled: bool, - #[case] query_helixmtdb_frequency: Option, - #[case] query_helixmtdb_heteroplasmic: Option, - #[case] query_helixmtdb_homoplasmic: Option, + #[case] query_helixmtdb_af: Option, + #[case] query_helixmtdb_het: Option, + #[case] query_helixmtdb_hom: Option, #[case] expected_pass_all: bool, ) -> Result<(), anyhow::Error> { let query = CaseQuery { frequency: QuerySettingsFrequency { helixmtdb: MitochondrialFrequencySettings { enabled: query_helixmtdb_enabled, - frequency: query_helixmtdb_frequency, - heteroplasmic: query_helixmtdb_heteroplasmic, - homoplasmic: query_helixmtdb_homoplasmic, + max_af: query_helixmtdb_af, + max_het: query_helixmtdb_het, + max_hom: query_helixmtdb_hom, }, ..Default::default() }, @@ -536,9 +533,9 @@ mod test { frequency: QuerySettingsFrequency { gnomad_mtdna: MitochondrialFrequencySettings { enabled: query_gnomad_mtdna_enabled, - frequency: query_gnomad_mtdna_frequency, - heteroplasmic: query_gnomad_mtdna_heteroplasmic, - homoplasmic: query_gnomad_mtdna_homoplasmic, + max_af: query_gnomad_mtdna_frequency, + max_het: query_gnomad_mtdna_heteroplasmic, + max_hom: query_gnomad_mtdna_homoplasmic, }, ..Default::default() }, diff --git a/src/seqvars/query/schema/query.rs b/src/seqvars/query/schema/query.rs index bef4d309..0f6da7c0 100644 --- a/src/seqvars/query/schema/query.rs +++ b/src/seqvars/query/schema/query.rs @@ -498,13 +498,13 @@ pub struct NuclearFrequencySettings { /// Whether to enable filtration by 1000 Genomes. pub enabled: bool, /// Maximal number of in-house heterozygous carriers. - pub heterozygous: Option, + pub max_het: Option, /// Maximal number of in-house homozygous carriers. - pub homozygous: Option, + pub max_hom: Option, /// Maximal number of in-house hemizygous carriers. - pub hemizygous: Option, + pub max_hemi: Option, /// Maximal allele frequency. - pub frequency: Option, + pub max_af: Option, } impl Eq for NuclearFrequencySettings {} @@ -513,10 +513,10 @@ impl From for NuclearFrequencySettings { fn from(value: pb_query::NuclearFrequencySettings) -> Self { Self { enabled: value.enabled, - heterozygous: value.heterozygous, - homozygous: value.homozygous, - hemizygous: value.hemizygous, - frequency: value.frequency, + max_het: value.max_het, + max_hom: value.max_hom, + max_hemi: value.max_hemi, + max_af: value.max_af, } } } @@ -527,11 +527,11 @@ pub struct MitochondrialFrequencySettings { /// Whether to enable filtration by mtDB. pub enabled: bool, /// Maximal number of heterozygous carriers in HelixMtDb. - pub heteroplasmic: Option, + pub max_het: Option, /// Maximal number of homozygous carriers in HelixMtDb. - pub homoplasmic: Option, + pub max_hom: Option, /// Maximal frequency in HelixMtDb. - pub frequency: Option, + pub max_af: Option, } impl Eq for MitochondrialFrequencySettings {} @@ -540,9 +540,9 @@ impl From for MitochondrialFrequencySe fn from(value: pb_query::MitochondrialFrequencySettings) -> Self { Self { enabled: value.enabled, - heteroplasmic: value.heteroplasmic, - homoplasmic: value.homoplasmic, - frequency: value.frequency, + max_het: value.max_het, + max_hom: value.max_hom, + max_af: value.max_af, } } } @@ -1633,17 +1633,17 @@ mod tests { fn test_gnomad_nuclear_frequency_settings_from() { let pb_gnomad_nuclear_frequency_settings = pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }; let gnomad_nuclear_frequency_settings = NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }; assert_eq!( NuclearFrequencySettings::from(pb_gnomad_nuclear_frequency_settings), @@ -1655,15 +1655,15 @@ mod tests { fn test_gnomad_mitochondrial_frequency_settings_from() { let pb_gnomad_mitochondrial_frequency_settings = pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }; let gnomad_mitochondrial_frequency_settings = MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }; assert_eq!( MitochondrialFrequencySettings::from(pb_gnomad_mitochondrial_frequency_settings), @@ -1675,15 +1675,15 @@ mod tests { fn test_helix_mtdb_frequency_settings_from() { let pb_helix_mtdb_frequency_settings = pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }; let helix_mtdb_frequency_settings = MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }; assert_eq!( MitochondrialFrequencySettings::from(pb_helix_mtdb_frequency_settings), @@ -1695,17 +1695,17 @@ mod tests { fn test_inhouse_frequency_settings_from() { let pb_inhouse_frequency_settings = pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }; let inhouse_frequency_settings = NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }; assert_eq!( NuclearFrequencySettings::from(pb_inhouse_frequency_settings), @@ -1718,71 +1718,71 @@ mod tests { let pb_query_settings_frequency = pb_query::QuerySettingsFrequency { gnomad_exomes: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), gnomad_genomes: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), gnomad_mtdna: Some(pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }), helixmtdb: Some(pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }), inhouse: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), }; let query_settings_frequency = QuerySettingsFrequency { gnomad_exomes: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, gnomad_genomes: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, gnomad_mtdna: MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }, helixmtdb: MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }, inhouse: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, }; assert_eq!( @@ -2145,36 +2145,36 @@ mod tests { frequency: Some(pb_query::QuerySettingsFrequency { gnomad_exomes: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), gnomad_genomes: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), gnomad_mtdna: Some(pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }), helixmtdb: Some(pb_query::MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }), inhouse: Some(pb_query::NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }), }), consequence: Some(pb_query::QuerySettingsConsequence { @@ -2255,36 +2255,36 @@ mod tests { frequency: QuerySettingsFrequency { gnomad_exomes: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, gnomad_genomes: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, gnomad_mtdna: MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }, helixmtdb: MitochondrialFrequencySettings { enabled: true, - heteroplasmic: Some(10), - homoplasmic: Some(20), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_af: Some(0.1), }, inhouse: NuclearFrequencySettings { enabled: true, - heterozygous: Some(10), - homozygous: Some(20), - hemizygous: Some(30), - frequency: Some(0.1), + max_het: Some(10), + max_hom: Some(20), + max_hemi: Some(30), + max_af: Some(0.1), }, }, consequence: QuerySettingsConsequence { diff --git a/src/seqvars/query/schema/snapshots/varfish_server_worker__seqvars__query__schema__query__tests__smoke_test_load@empty.json.snap b/src/seqvars/query/schema/snapshots/varfish_server_worker__seqvars__query__schema__query__tests__smoke_test_load@empty.json.snap index 0c73ea17..72cb05b7 100644 --- a/src/seqvars/query/schema/snapshots/varfish_server_worker__seqvars__query__schema__query__tests__smoke_test_load@empty.json.snap +++ b/src/seqvars/query/schema/snapshots/varfish_server_worker__seqvars__query__schema__query__tests__smoke_test_load@empty.json.snap @@ -10,32 +10,32 @@ quality: frequency: gnomad_exomes: enabled: false - heterozygous: ~ - homozygous: ~ - hemizygous: ~ - frequency: ~ + max_het: ~ + max_hom: ~ + max_hemi: ~ + max_af: ~ gnomad_genomes: enabled: false - heterozygous: ~ - homozygous: ~ - hemizygous: ~ - frequency: ~ + max_het: ~ + max_hom: ~ + max_hemi: ~ + max_af: ~ gnomad_mtdna: enabled: false - heteroplasmic: ~ - homoplasmic: ~ - frequency: ~ + max_het: ~ + max_hom: ~ + max_af: ~ helixmtdb: enabled: false - heteroplasmic: ~ - homoplasmic: ~ - frequency: ~ + max_het: ~ + max_hom: ~ + max_af: ~ inhouse: enabled: false - heterozygous: ~ - homozygous: ~ - hemizygous: ~ - frequency: ~ + max_het: ~ + max_hom: ~ + max_hemi: ~ + max_af: ~ consequence: variant_types: [] transcript_types: []