Skip to content

Commit

Permalink
fix: changing protobuf and others as needed (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Sep 3, 2024
1 parent 843922a commit 2718a6e
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 183 deletions.
2 changes: 1 addition & 1 deletion protos/varfish/v1/seqvars/output.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ message GeneIdentity {
/// Gene-related consequences of a variant.
message GeneRelatedConsequences {
// HGVS. {c,n} code of variant.
string hgvs_t = 1;
optional string hgvs_t = 1;
// HGVS.p code of variant.
optional string hgvs_p = 2;
// Predicted variant consequences.
Expand Down
66 changes: 43 additions & 23 deletions protos/varfish/v1/seqvars/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -190,61 +190,81 @@ enum Consequence {
CONSEQUENCE_START_LOST = 8;
// Transcript amplification
CONSEQUENCE_TRANSCRIPT_AMPLIFICATION = 9;
// Feature elongation.
CONSEQUENCE_FEATURE_ELONGATION = 10;
// Feature truncation.
CONSEQUENCE_FEATURE_TRUNCATION = 11;
/*
* moderate impact
*/
// Disruptive inframe insertion
CONSEQUENCE_DISRUPTIVE_INFRAME_INSERTION = 10;
CONSEQUENCE_DISRUPTIVE_INFRAME_INSERTION = 12;
// Disruptive inframe deletion
CONSEQUENCE_DISRUPTIVE_INFRAME_DELETION = 11;
CONSEQUENCE_DISRUPTIVE_INFRAME_DELETION = 13;
// Conservative inframe insertion
CONSEQUENCE_CONSERVATIVE_INFRAME_INSERTION = 12;
CONSEQUENCE_CONSERVATIVE_INFRAME_INSERTION = 14;
// Conservative inframe deletion
CONSEQUENCE_CONSERVATIVE_INFRAME_DELETION = 13;
CONSEQUENCE_CONSERVATIVE_INFRAME_DELETION = 15;
// Missense variant
CONSEQUENCE_MISSENSE_VARIANT = 14;
CONSEQUENCE_MISSENSE_VARIANT = 16;
/*
* low impact
*/
// Splice donor 5th base variant.
CONSEQUENCE_SPLICE_DONOR_FIFTH_BASE_VARIANT = 15;
CONSEQUENCE_SPLICE_DONOR_FIFTH_BASE_VARIANT = 17;
// Splice region variant.
CONSEQUENCE_SPLICE_REGION_VARIANT = 16;
CONSEQUENCE_SPLICE_REGION_VARIANT = 18;
// Splice donor region variant.
CONSEQUENCE_SPLICE_DONOR_REGION_VARIANT = 17;
CONSEQUENCE_SPLICE_DONOR_REGION_VARIANT = 19;
// Splice polypyrimidine tract variant.
CONSEQUENCE_SPLICE_POLYPYRIMIDINE_TRACT_VARIANT = 18;
CONSEQUENCE_SPLICE_POLYPYRIMIDINE_TRACT_VARIANT = 20;
// Start retained variant.
CONSEQUENCE_START_RETAINED_VARIANT = 19;
CONSEQUENCE_START_RETAINED_VARIANT = 21;
// Stop retained variant.
CONSEQUENCE_STOP_RETAINED_VARIANT = 20;
CONSEQUENCE_STOP_RETAINED_VARIANT = 22;
// Synonymous variant.
CONSEQUENCE_SYNONYMOUS_VARIANT = 21;
CONSEQUENCE_SYNONYMOUS_VARIANT = 23;
/*
* modifier
*/
// Coding sequence variant.
CONSEQUENCE_CODING_SEQUENCE_VARIANT = 22;
CONSEQUENCE_CODING_SEQUENCE_VARIANT = 24;
// Mature miRNA variant.
CONSEQUENCE_MATURE_MIRNA_VARIANT = 25;
// 5' UTR exon variant.
CONSEQUENCE_FIVE_PRIME_UTR_EXON_VARIANT = 23;
CONSEQUENCE_FIVE_PRIME_UTR_EXON_VARIANT = 26;
// 5' UTR intron variant.
CONSEQUENCE_FIVE_PRIME_UTR_INTRON_VARIANT = 24;
CONSEQUENCE_FIVE_PRIME_UTR_INTRON_VARIANT = 27;
// 3' UTR exon variant.
CONSEQUENCE_THREE_PRIME_UTR_EXON_VARIANT = 25;
CONSEQUENCE_THREE_PRIME_UTR_EXON_VARIANT = 28;
// 3' UTR intron variant.
CONSEQUENCE_THREE_PRIME_UTR_INTRON_VARIANT = 26;
CONSEQUENCE_THREE_PRIME_UTR_INTRON_VARIANT = 29;
// Non-coding transcript exon variant.
CONSEQUENCE_NON_CODING_TRANSCRIPT_EXON_VARIANT = 27;
CONSEQUENCE_NON_CODING_TRANSCRIPT_EXON_VARIANT = 30;
// Non-coding transcript intron variant.
CONSEQUENCE_NON_CODING_TRANSCRIPT_INTRON_VARIANT = 28;
CONSEQUENCE_NON_CODING_TRANSCRIPT_INTRON_VARIANT = 31;
// Upstream gene variant.
CONSEQUENCE_UPSTREAM_GENE_VARIANT = 29;
CONSEQUENCE_UPSTREAM_GENE_VARIANT = 32;
// Downstream gene variant.
CONSEQUENCE_DOWNSTREAM_GENE_VARIANT = 30;
CONSEQUENCE_DOWNSTREAM_GENE_VARIANT = 33;
// TFBS ablation.
CONSEQUENCE_TFBS_ABLATION = 34;
// TFBS amplification.
CONSEQUENCE_TFBS_AMPLIFICATION = 35;
// TFBS binding site variant.
CONSEQUENCE_TF_BINDING_SITE_VARIANT = 36;
// Regulatory region ablation.
CONSEQUENCE_REGULATORY_REGION_ABLATION = 37;
// Regulatory region amplification.
CONSEQUENCE_REGULATORY_REGION_AMPLIFICATION = 38;
// Regulatory region variant.
CONSEQUENCE_REGULATORY_REGION_VARIANT = 39;
// Intergenic variant.
CONSEQUENCE_INTERGENIC_VARIANT = 31;
CONSEQUENCE_INTERGENIC_VARIANT = 40;
// Intron variant.
CONSEQUENCE_INTRON_VARIANT = 32;
CONSEQUENCE_INTRON_VARIANT = 41;
// Gene variant.
CONSEQUENCE_GENE_VARIANT = 42;
}

// Consequence-related filter settings.
Expand Down
166 changes: 70 additions & 96 deletions src/seqvars/aggregate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,102 +459,76 @@ mod test {

#[test]
fn test_is_par() {
assert_eq!(
super::is_par(super::Chrom::X, 60000, crate::common::GenomeRelease::Grch37),
false
);
assert_eq!(
super::is_par(super::Chrom::X, 60001, crate::common::GenomeRelease::Grch37),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
2699520,
crate::common::GenomeRelease::Grch37
),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
2699521,
crate::common::GenomeRelease::Grch37
),
false
);
assert_eq!(
super::is_par(
super::Chrom::X,
154931043,
crate::common::GenomeRelease::Grch37
),
false
);
assert_eq!(
super::is_par(
super::Chrom::X,
154931044,
crate::common::GenomeRelease::Grch37
),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
155260560,
crate::common::GenomeRelease::Grch37
),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
155260561,
crate::common::GenomeRelease::Grch37
),
false
);
assert_eq!(
super::is_par(
super::Chrom::X,
155260561,
crate::common::GenomeRelease::Grch38
),
false
);
assert_eq!(
super::is_par(
super::Chrom::X,
155701383,
crate::common::GenomeRelease::Grch38
),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
156030895,
crate::common::GenomeRelease::Grch38
),
true
);
assert_eq!(
super::is_par(
super::Chrom::X,
156030896,
crate::common::GenomeRelease::Grch38
),
false
);
assert_eq!(
super::is_par(super::Chrom::Y, 10000, crate::common::GenomeRelease::Grch37),
false
);
assert_eq!(
super::is_par(super::Chrom::Y, 10001, crate::common::GenomeRelease::Grch37),
true
);
assert!(!super::is_par(
super::Chrom::X,
60000,
crate::common::GenomeRelease::Grch37
));
assert!(super::is_par(
super::Chrom::X,
60001,
crate::common::GenomeRelease::Grch37
));
assert!(super::is_par(
super::Chrom::X,
2699520,
crate::common::GenomeRelease::Grch37
));
assert!(!super::is_par(
super::Chrom::X,
2699521,
crate::common::GenomeRelease::Grch37
));
assert!(!super::is_par(
super::Chrom::X,
154931043,
crate::common::GenomeRelease::Grch37
));
assert!(super::is_par(
super::Chrom::X,
154931044,
crate::common::GenomeRelease::Grch37
));
assert!(super::is_par(
super::Chrom::X,
155260560,
crate::common::GenomeRelease::Grch37
));
assert!(!super::is_par(
super::Chrom::X,
155260561,
crate::common::GenomeRelease::Grch37
));
assert!(!super::is_par(
super::Chrom::X,
155260561,
crate::common::GenomeRelease::Grch38
));
assert!(super::is_par(
super::Chrom::X,
155701383,
crate::common::GenomeRelease::Grch38
));
assert!(super::is_par(
super::Chrom::X,
156030895,
crate::common::GenomeRelease::Grch38
));
assert!(!super::is_par(
super::Chrom::X,
156030896,
crate::common::GenomeRelease::Grch38
));
assert!(!super::is_par(
super::Chrom::Y,
10000,
crate::common::GenomeRelease::Grch37
));
assert!(super::is_par(
super::Chrom::Y,
10001,
crate::common::GenomeRelease::Grch37
));
}

#[tracing_test::traced_test]
Expand Down
3 changes: 1 addition & 2 deletions src/seqvars/query/interpreter/quality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ mod test {
Ok(())
}

#[rstest::rstest]
#[allow(clippy::too_many_arguments)]
#[rstest::rstest]
// het, pass dp
#[case(
Some(10), // q_min_dp_het
Expand Down Expand Up @@ -421,7 +421,6 @@ mod test {
None, // c_ad
true, // expected
)]
#[allow(clippy::too_many_arguments)]
fn passes_for_sample(
#[case] q_min_dp_het: Option<i32>,
#[case] q_min_dp_hom: Option<i32>,
Expand Down
35 changes: 21 additions & 14 deletions src/seqvars/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Args {
pub result_set_id: Option<String>,
/// The case UUID.
#[arg(long)]
pub case_uuid_id: Option<uuid::Uuid>,
pub case_uuid: Option<uuid::Uuid>,
/// Path to worker database to use for querying.
#[arg(long)]
pub path_db: String,
Expand Down Expand Up @@ -522,18 +522,27 @@ fn write_header(
version: common::worker_version().to_string(),
}],
query: Some(pb_query.clone()),
case_uuid: args.case_uuid_id.unwrap_or_default().to_string(),
case_uuid: args.case_uuid.unwrap_or_default().to_string(),
statistics: Some(pbs_output::OutputStatistics {
count_total: stats.count_total as u64,
count_passed: stats.count_passed as u64,
passed_by_consequences: stats
.passed_by_consequences
.iter()
.map(|(k, v)| pbs_output::ConsequenceCount {
consequence: *k as i32,
count: *v as u32,
})
.collect(),
.map(
|(csq, count)| -> Result<pbs_output::ConsequenceCount, anyhow::Error> {
Ok(pbs_output::ConsequenceCount {
consequence: TryInto::<pbs_query::Consequence>::try_into(*csq).map_err(
|e| {
anyhow::anyhow!("could not convert consequence {}: {}", *csq, e)
},
)? as i32,
count: *count as u32,
})
},
)
.collect::<Result<_, _>>()
.map_err(|e| anyhow::anyhow!("could not convert consequences: {}", e))?,
}),
resources: Some(pbs_output::ResourcesUsed {
start_time: Some(start_time),
Expand Down Expand Up @@ -727,11 +736,9 @@ mod gene_related_annotation {
pub(crate) fn consequences(
ann: &mehari::annotate::seqvars::ann::AnnField,
) -> Result<Option<pbs_output::GeneRelatedConsequences>, anyhow::Error> {
eprintln!("{:?}", &ann);
Ok(Some(pbs_output::GeneRelatedConsequences {
hgvs_t: ann
.hgvs_t
.clone()
.ok_or_else(|| anyhow::anyhow!("missing hgvs_t annotation"))?,
hgvs_t: ann.hgvs_t.clone(),
hgvs_p: ann.hgvs_p.clone(),
consequences: ann
.consequences
Expand Down Expand Up @@ -1309,7 +1316,7 @@ async fn create_and_write_record(
*uuid_buf
})
.to_string(),
case_uuid: args.case_uuid_id.unwrap_or_default().to_string(),
case_uuid: args.case_uuid.unwrap_or_default().to_string(),
vcf_variant: Some(pbs_output::VcfVariant {
genome_release: Into::<pbs_output::GenomeRelease>::into(args.genome_release) as i32,
chrom: seqvar.vcf_variant.chrom.clone(),
Expand Down Expand Up @@ -1350,12 +1357,12 @@ async fn create_and_write_record(
&mut buf,
"{}",
serde_json::to_string(&record)
.map_err(|e| anyhow::anyhow!("could not convert header to JSON: {}", e))?
.map_err(|e| anyhow::anyhow!("could not convert record to JSON: {}", e))?
)?;
writer
.write_all(&buf)
.await
.map_err(|e| anyhow::anyhow!("could not write header to output file: {}", e))
.map_err(|e| anyhow::anyhow!("could not write record to output file: {}", e))
}

/// Main entry point for `seqvars query` sub command.
Expand Down
Loading

0 comments on commit 2718a6e

Please sign in to comment.