Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: suppress unknown consequence errors #491

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/seqvars/ingest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async fn process_variants(

// Open the serialized transcripts.
tracing::info!("Opening transcript database");
let tx_db = mehari::annotate::seqvars::load_tx_db(&format!(
let tx_db = mehari::annotate::seqvars::load_tx_db(format!(
"{}/{}/txs.bin.zst",
&args.path_mehari_db,
path_component(args.genomebuild)
Expand Down
40 changes: 21 additions & 19 deletions src/seqvars/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async fn run_query(
stats.count_total += 1;
let record_seqvar = VariantRecord::try_from_vcf(&record_buf, &input_header)
.map_err(|e| anyhow::anyhow!("could not parse VCF record: {}", e))?;
tracing::debug!("processing record {:?}", record_seqvar);
tracing::trace!("processing record {:?}", record_seqvar);

if interpreter.passes(&record_seqvar, annotator)?.pass_all {
stats.count_passed += 1;
Expand Down Expand Up @@ -424,6 +424,7 @@ async fn run_query(

// Perform the annotation and write into file without header.
{
tracing::debug!("writing noheader file {}", path_noheader.display());
let writer = tokio::fs::OpenOptions::new()
.create(true)
.truncate(true)
Expand Down Expand Up @@ -477,6 +478,7 @@ async fn run_query(
// Use output helper for semi-transparent upload to S3.
let out_path_helper = crate::common::s3::OutputPathHelper::new(&args.path_output)?;
{
tracing::debug!("writing file {}", out_path_helper.path_out());
// Open output file for writing (potentially temporary, then uploaded to S3 via helper).
let file = std::fs::OpenOptions::new()
.create(true)
Expand Down Expand Up @@ -529,20 +531,18 @@ fn write_header(
passed_by_consequences: stats
.passed_by_consequences
.iter()
.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,
.filter_map(|(csq, count)| -> Option<pbs_output::ConsequenceCount> {
// We ignore consequences that don't have a mapping into the protobuf.
if let Ok(csq) = TryInto::<pbs_query::Consequence>::try_into(*csq) {
Some(pbs_output::ConsequenceCount {
consequence: csq as i32,
count: *count as u32,
})
},
)
.collect::<Result<_, _>>()
.map_err(|e| anyhow::anyhow!("could not convert consequences: {}", e))?,
} else {
None
}
})
.collect::<Vec<_>>(),
holtgrewe marked this conversation as resolved.
Show resolved Hide resolved
}),
resources: Some(pbs_output::ResourcesUsed {
start_time: Some(start_time),
Expand Down Expand Up @@ -742,13 +742,15 @@ mod gene_related_annotation {
consequences: ann
.consequences
.iter()
.map(|csq| -> Result<i32, anyhow::Error> {
let csq: pbs_query::Consequence = (*csq)
.try_into()
.map_err(|e| anyhow::anyhow!("could not convert consequence: {}", e))?;
Ok(csq as i32)
.filter_map(|csq| -> Option<i32> {
// We ignore consequences that don't have a mapping into the protobuf.
if let Ok(csq) = TryInto::<pbs_query::Consequence>::try_into(*csq) {
Some(csq as i32)
} else {
None
}
})
.collect::<Result<Vec<_>, _>>()?,
.collect::<Vec<_>>(),
}))
}

Expand Down
2 changes: 1 addition & 1 deletion src/strucvars/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ async fn run_query(
let record_sv = StructuralVariant::from_vcf(&record_buf, &input_header)
.map_err(|e| anyhow::anyhow!("could not parse VCF record: {}", e))?;

tracing::debug!("processing record {:?}", record_sv);
tracing::trace!("processing record {:?}", record_sv);

let mut result_payload = ResultPayload {
call_info: record_sv.call_info.clone(),
Expand Down
Loading