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: re-enable gnomad output for server #604

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
100 changes: 97 additions & 3 deletions src/server/run/annos_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2924,8 +2924,103 @@ pub async fn handle_with_openapi(
.transpose()?
.flatten()
.map(Into::into),
// gnomad_exomes: Option<bool>,
// gnomad_genomes: Option<bool>,
gnomad_exomes: data.annos[genome_release][AnnoDb::GnomadExomes]
.as_ref()
.map(|db| {
let db_version = data.db_infos[genome_release][AnnoDb::GnomadExomes]
.as_ref()
.expect("must have db info here")
.db_version
.as_ref()
.expect("gnomAD must have db version");
if db_version.starts_with("2.") {
Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad2::Record>(
&db.data,
AnnoDb::GnomadExomes.cf_name(),
query.clone().into_inner().into(),
)?
.map(|record| {
Ok(GnomadRecord::Gnomad2(
record.try_into().map_err(CustomError::new)?,
))
})
.transpose()?)
} else if db_version.starts_with("3.") {
Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad3::Record>(
&db.data,
AnnoDb::GnomadExomes.cf_name(),
query.clone().into_inner().into(),
)?
.map(|record| {
Ok(GnomadRecord::Gnomad3(
record.try_into().map_err(CustomError::new)?,
))
})
.transpose()?)
} else if db_version.starts_with("4.") {
Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad4::Record>(
&db.data,
AnnoDb::GnomadExomes.cf_name(),
query.clone().into_inner().into(),
)?
.map(|record| {
Ok(GnomadRecord::Gnomad4(
record.try_into().map_err(CustomError::new)?,
))
})
.transpose()?)
} else {
Err(CustomError::new(anyhow::anyhow!(
"don't know how to handle gnomAD version {}",
db_version
)))
}
})
.transpose()?
.flatten(),
gnomad_genomes: data.annos[genome_release][AnnoDb::GnomadGenomes]
.as_ref()
.map(|db| {
let db_version = data.db_infos[genome_release][AnnoDb::GnomadGenomes]
.as_ref()
.expect("must have db info here")
.db_version
.as_ref()
.expect("gnomAD must have db version");

if db_version.starts_with("2.") {
Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad2::Record>(
&db.data,
AnnoDb::GnomadGenomes.cf_name(),
query.clone().into_inner().into(),
)?
.map(|record| {
Ok(GnomadRecord::Gnomad2(
record.try_into().map_err(CustomError::new)?,
))
})
.transpose()?)
} else if db_version.starts_with("4.") {
Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad4::Record>(
&db.data,
AnnoDb::GnomadGenomes.cf_name(),
query.clone().into_inner().into(),
)?
.map(|record| {
Ok(GnomadRecord::Gnomad4(
record.try_into().map_err(CustomError::new)?,
))
})
.transpose()?)
} else {
Err(CustomError::new(anyhow::anyhow!(
"don't know how to handle gnomAD version {}",
db_version
)))
}
Comment on lines +2991 to +3020
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing handling for gnomAD Genomes version 3.x

The code does not handle gnomAD Genomes version 3.x in the gnomad_genomes block. This could lead to runtime errors if db_version starts with "3.".

Apply this diff to fix the issue:

                     if db_version.starts_with("2.") {
                         // existing code for version 2.x
+                    } else if db_version.starts_with("3.") {
+                        Ok(fetch_var_protobuf::<crate::pbs::gnomad::gnomad3::Record>(
+                            &db.data,
+                            AnnoDb::GnomadGenomes.cf_name(),
+                            query.clone().into_inner().into(),
+                        )?
+                        .map(|record| {
+                            Ok(GnomadRecord::Gnomad3(
+                                record.try_into().map_err(CustomError::new)?,
+                            ))
+                        })
+                        .transpose()?)
                     } else if db_version.starts_with("4.") {
                         // existing code for version 4.x
                     } else {
                         // existing error handling
                     }

Committable suggestion skipped: line range outside the PR's diff.

})
.transpose()?
.flatten(),
helixmtdb: data.annos[genome_release][AnnoDb::Helixmtdb]
.as_ref()
.map(|db| {
Expand Down Expand Up @@ -2973,7 +3068,6 @@ pub async fn handle_with_openapi(
})
.transpose()?
.flatten(),
..Default::default()
};

Ok(Json(SeqvarsAnnosResponse { result }))
Expand Down
Loading