Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Dec 28, 2023
1 parent 276f217 commit bfeefee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/gnomad_nuclear/cli/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn open_rocksdb_from_args(
fn print_record(
out_writer: &mut Box<dyn std::io::Write>,
output_format: common::cli::OutputFormat,
value: &Box<dyn SerializeRecordTrait>,
value: &dyn SerializeRecordTrait,
) -> Result<(), anyhow::Error> {
match output_format {
common::cli::OutputFormat::Jsonl => {
Expand Down Expand Up @@ -179,7 +179,7 @@ pub fn run(common: &common::cli::Args, args: &Args) -> Result<(), anyhow::Error>
_ => unreachable!("unhandled gnomAD version: {}", &meta.gnomad_version),
};
if let Some(record) = query_result {
print_record(&mut out_writer, args.out_format, &record)?
print_record(&mut out_writer, args.out_format, record.as_ref())?
} else {
tracing::info!("no record found for variant {:?}", &variant);
}
Expand Down Expand Up @@ -244,7 +244,7 @@ pub fn run(common: &common::cli::Args, args: &Args) -> Result<(), anyhow::Error>
'4' => Box::new(pbs::gnomad::gnomad4::Record::decode(&mut cursor)?),
_ => unreachable!("unhandled gnomAD version: {}", &meta.gnomad_version),
};
print_record(&mut out_writer, args.out_format, &record)?;
print_record(&mut out_writer, args.out_format, record.as_ref())?;
iter.next();
} else {
break;
Expand Down
36 changes: 31 additions & 5 deletions src/server/actix_server/annos_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,31 @@ async fn handle(
data.annos[genome_release][anno_db]
.as_ref()
.map(|db| {
fetch_var_protobuf::<crate::pbs::gnomad::gnomad2::Record>(
db,
anno_db.cf_name(),
query.clone().into_inner().into(),
)
let db_version = data.db_infos[genome_release][anno_db]

Check warning on line 156 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L156

Added line #L156 was not covered by tests
.as_ref()
.expect("must have db info here")
.db_version
.as_ref()
.expect("gnomAD must have db version");

if db_version.starts_with("2.") {
fetch_var_protobuf::<crate::pbs::gnomad::gnomad2::Record>(

Check warning on line 164 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L163-L164

Added lines #L163 - L164 were not covered by tests
db,
anno_db.cf_name(),
query.clone().into_inner().into(),

Check warning on line 167 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L166-L167

Added lines #L166 - L167 were not covered by tests
)
} else if db_version.starts_with("4.") {
fetch_var_protobuf::<crate::pbs::gnomad::gnomad4::Record>(

Check warning on line 170 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L169-L170

Added lines #L169 - L170 were not covered by tests
db,
anno_db.cf_name(),
query.clone().into_inner().into(),

Check warning on line 173 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L172-L173

Added lines #L172 - L173 were not covered by tests
)
} else {
Err(CustomError::new(anyhow::anyhow!(

Check warning on line 176 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L176

Added line #L176 was not covered by tests
"don't know how to tread gnomAD version {}",
db_version
)))
}
})
.transpose()?
.map(|v| annotations.insert(anno_db, v));
Expand All @@ -184,6 +204,12 @@ async fn handle(
anno_db.cf_name(),
query.clone().into_inner().into(),
)
} else if db_version.starts_with("4.") {
fetch_var_protobuf::<crate::pbs::gnomad::gnomad4::Record>(

Check warning on line 208 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L207-L208

Added lines #L207 - L208 were not covered by tests
db,
anno_db.cf_name(),
query.clone().into_inner().into(),

Check warning on line 211 in src/server/actix_server/annos_variant.rs

View check run for this annotation

Codecov / codecov/patch

src/server/actix_server/annos_variant.rs#L210-L211

Added lines #L210 - L211 were not covered by tests
)
} else {
Err(CustomError::new(anyhow::anyhow!(
"don't know how to tread gnomAD version {}",
Expand Down

0 comments on commit bfeefee

Please sign in to comment.