Skip to content

Commit

Permalink
refactor: consolidating protobuf definitions (#508) (#509)
Browse files Browse the repository at this point in the history
Release-As: 0.16.0
  • Loading branch information
holtgrewe authored Oct 25, 2024
1 parent fd08d42 commit 0edcf98
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 111 deletions.
20 changes: 4 additions & 16 deletions protos/varfish/v1/seqvars/output.proto
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ message FrequencyAnnotation {
// gnomAD-genomes filter
optional NuclearFrequency gnomad_genomes = 2;
// gnomAD-MT filter
optional GnomadMitochondrialFrequency gnomad_mtdna = 3;
optional MitochondrialFrequency gnomad_mtdna = 3;
// HelixMtDb filter
optional HelixMtDbFrequency helixmtdb = 4;
optional MitochondrialFrequency helixmtdb = 4;
// In-house filter
optional NuclearFrequency inhouse = 5;
}
Expand All @@ -356,8 +356,8 @@ message NuclearFrequency {
float af = 5;
}

// gnomAD mitochondrial frequency information.
message GnomadMitochondrialFrequency {
// Mitochondrial frequency information.
message MitochondrialFrequency {
// Number of covered alleles.
int32 an = 1;
// Number of heteroplasmic carriers.
Expand All @@ -368,18 +368,6 @@ message GnomadMitochondrialFrequency {
float af = 4;
}

// HelixMtDb frequency information.
message HelixMtDbFrequency {
// Number of covered alleles.
int32 an = 1;
// Number of heterozygous carriers in HelixMtDb
int32 het = 2;
// Number of homozygous carriers in HelixMtDb
int32 homalt = 3;
// Frequency in HelixMtDb
float af = 4;
}

// Database identifiers.
message DbIds {
// dbSNP ID.
Expand Down
23 changes: 5 additions & 18 deletions protos/varfish/v1/seqvars/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ message NuclearFrequencySettings {
optional float frequency = 5;
}

// gnomAD mitochondrial filter options.
message GnomadMitochondrialFrequencySettings {
// Mitochondrial filter options.
message MitochondrialFrequencySettings {
// Whether to enable filtration by 1000 Genomes.
bool enabled = 1;
// Maximal number of heteroplasmic carriers.
Expand All @@ -114,29 +114,16 @@ message GnomadMitochondrialFrequencySettings {
optional float frequency = 4;
}

// HelixMtDb filter options.
message HelixMtDbFrequencySettings {
// Whether to enable filtration by mtDB
bool enabled = 1;
// Maximal number of heterozygous carriers in HelixMtDb
optional int32 heteroplasmic = 2;
// Maximal number of homozygous carriers in HelixMtDb
optional int32 homoplasmic = 3;
// Maximal frequency in HelixMtDb
optional float frequency = 4;
}


// Population frequency filter options.
message QuerySettingsFrequency {
// gnomAD-exomes filter
NuclearFrequencySettings gnomad_exomes = 1;
// gnomAD-genomes filter
NuclearFrequencySettings gnomad_genomes = 2;
// gnomAD-MT filter
GnomadMitochondrialFrequencySettings gnomad_mtdna = 3;
MitochondrialFrequencySettings gnomad_mtdna = 3;
// HelixMtDb filter
HelixMtDbFrequencySettings helixmtdb = 4;
MitochondrialFrequencySettings helixmtdb = 4;
// In-house filter
NuclearFrequencySettings inhouse = 5;
}
Expand Down Expand Up @@ -284,7 +271,7 @@ message Range {
// 1-based start position.
int32 start = 1;
// 1-based end position.
int32 end = 2;
int32 stop = 2;
}

// Genomic region.
Expand Down
8 changes: 4 additions & 4 deletions src/seqvars/query/interpreter/frequency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ mod test {
VcfVariant,
},
query::{
CaseQuery, GnomadMitochondrialFrequencySettings, HelixMtDbFrequencySettings,
NuclearFrequencySettings, QuerySettingsFrequency,
CaseQuery, MitochondrialFrequencySettings, NuclearFrequencySettings,
QuerySettingsFrequency,
},
};

Expand Down Expand Up @@ -423,7 +423,7 @@ mod test {
) -> Result<(), anyhow::Error> {
let query = CaseQuery {
frequency: QuerySettingsFrequency {
helixmtdb: HelixMtDbFrequencySettings {
helixmtdb: MitochondrialFrequencySettings {
enabled: query_helixmtdb_enabled,
frequency: query_helixmtdb_frequency,
heteroplasmic: query_helixmtdb_heteroplasmic,
Expand Down Expand Up @@ -534,7 +534,7 @@ mod test {
) -> Result<(), anyhow::Error> {
let query = CaseQuery {
frequency: QuerySettingsFrequency {
gnomad_mtdna: GnomadMitochondrialFrequencySettings {
gnomad_mtdna: MitochondrialFrequencySettings {
enabled: query_gnomad_mtdna_enabled,
frequency: query_gnomad_mtdna_frequency,
heteroplasmic: query_gnomad_mtdna_heteroplasmic,
Expand Down
14 changes: 7 additions & 7 deletions src/seqvars/query/interpreter/regions_allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn passes(query: &CaseQuery, seqvar: &VariantRecord) -> bool {
}
}

fn overlaps(region: &GenomicRegion, seqvar_chrom: &str, seqvar_pos: i32, seqvar_end: i32) -> bool {
fn overlaps(region: &GenomicRegion, seqvar_chrom: &str, seqvar_pos: i32, seqvar_stop: i32) -> bool {
let GenomicRegion {
chrom: region_chrom,
range: region_range,
Expand All @@ -39,10 +39,10 @@ fn overlaps(region: &GenomicRegion, seqvar_chrom: &str, seqvar_pos: i32, seqvar_

if let Some(Range {
start: region_start,
end: region_end,
stop: region_stop,
}) = region_range
{
*region_start <= seqvar_end && *region_end >= seqvar_pos
*region_start <= seqvar_stop && *region_stop >= seqvar_pos
} else {
true
}
Expand All @@ -64,18 +64,18 @@ mod test {
#[case] region_range: Option<(i32, i32)>,
#[case] seqvar_chrom: &str,
#[case] seqvar_start: i32,
#[case] seqvar_end: i32,
#[case] seqvar_stop: i32,
#[case] expected: bool,
) {
let region = super::GenomicRegion {
chrom: String::from(region_chrom),
range: region_range.map(|(region_start, region_end)| super::Range {
range: region_range.map(|(region_start, region_stop)| super::Range {
start: region_start,
end: region_end,
stop: region_stop,
}),
};
assert_eq!(
super::overlaps(&region, seqvar_chrom, seqvar_start, seqvar_end),
super::overlaps(&region, seqvar_chrom, seqvar_start, seqvar_stop),
expected
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/seqvars/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,13 +1123,13 @@ mod variant_related_annotation {
hemialt: seqvar.population_frequencies.gnomad_genomes.hemi,
af: seqvar.population_frequencies.gnomad_genomes.af(),
}),
gnomad_mtdna: Some(pbs_output::GnomadMitochondrialFrequency {
gnomad_mtdna: Some(pbs_output::MitochondrialFrequency {
an: seqvar.population_frequencies.gnomad_mtdna.an,
het: seqvar.population_frequencies.gnomad_mtdna.het,
homalt: seqvar.population_frequencies.gnomad_mtdna.hom,
af: seqvar.population_frequencies.gnomad_mtdna.af(),
}),
helixmtdb: Some(pbs_output::HelixMtDbFrequency {
helixmtdb: Some(pbs_output::MitochondrialFrequency {
an: seqvar.population_frequencies.helixmtdb.an,
het: seqvar.population_frequencies.helixmtdb.het,
homalt: seqvar.population_frequencies.helixmtdb.hom,
Expand Down
Loading

0 comments on commit 0edcf98

Please sign in to comment.