diff --git a/src/gnomad_nuclear/cli/query.rs b/src/gnomad_nuclear/cli/query.rs index fd1ba75a..58dbd9f8 100644 --- a/src/gnomad_nuclear/cli/query.rs +++ b/src/gnomad_nuclear/cli/query.rs @@ -101,7 +101,7 @@ pub fn open_rocksdb_from_args( fn print_record( out_writer: &mut Box, output_format: common::cli::OutputFormat, - value: &Box, + value: &dyn SerializeRecordTrait, ) -> Result<(), anyhow::Error> { match output_format { common::cli::OutputFormat::Jsonl => { @@ -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); } @@ -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; diff --git a/src/server/actix_server/annos_variant.rs b/src/server/actix_server/annos_variant.rs index 8c65a8bb..3b9f974b 100644 --- a/src/server/actix_server/annos_variant.rs +++ b/src/server/actix_server/annos_variant.rs @@ -153,11 +153,31 @@ async fn handle( data.annos[genome_release][anno_db] .as_ref() .map(|db| { - fetch_var_protobuf::( - db, - anno_db.cf_name(), - query.clone().into_inner().into(), - ) + let db_version = data.db_infos[genome_release][anno_db] + .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::( + db, + anno_db.cf_name(), + query.clone().into_inner().into(), + ) + } else if db_version.starts_with("4.") { + fetch_var_protobuf::( + db, + anno_db.cf_name(), + query.clone().into_inner().into(), + ) + } else { + Err(CustomError::new(anyhow::anyhow!( + "don't know how to tread gnomAD version {}", + db_version + ))) + } }) .transpose()? .map(|v| annotations.insert(anno_db, v)); @@ -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::( + db, + anno_db.cf_name(), + query.clone().into_inner().into(), + ) } else { Err(CustomError::new(anyhow::anyhow!( "don't know how to tread gnomAD version {}",