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 5517687 commit 276f217
Show file tree
Hide file tree
Showing 26 changed files with 255 additions and 22 deletions.
62 changes: 56 additions & 6 deletions src/gnomad_nuclear/cli/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub enum GnomadKind {
Genomes,
}

impl Into<crate::pbs::gnomad::gnomad4::RecordType> for GnomadKind {
fn into(self) -> crate::pbs::gnomad::gnomad4::RecordType {
match self {
impl From<GnomadKind> for crate::pbs::gnomad::gnomad4::RecordType {
fn from(val: GnomadKind) -> Self {
match val {
GnomadKind::Exomes => crate::pbs::gnomad::gnomad4::RecordType::Exomes,
GnomadKind::Genomes => crate::pbs::gnomad::gnomad4::RecordType::Genomes,
}
Expand Down Expand Up @@ -414,7 +414,7 @@ pub fn run(common: &common::cli::Args, args: &Args) -> Result<(), anyhow::Error>
for (header_field, val) in more_header_values {
db.put_cf(
&cf_meta,
&format!("gnomad-{}", header_field.replace("_", "-")),
&format!("gnomad-{}", header_field.replace('_', "-")),
&val,
)?;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ mod test {
}

#[test]
fn smoke_test_import_gnomad_exomes_grch38() -> Result<(), anyhow::Error> {
fn smoke_test_import_gnomad_exomes_grch38_v2_1() -> Result<(), anyhow::Error> {
let tmp_dir = TempDir::default();
let common = common::cli::Args {
verbose: Verbosity::new(1, 0),
Expand All @@ -529,7 +529,7 @@ mod test {
}

#[test]
fn smoke_test_import_gnomad_genomes_grch38() -> Result<(), anyhow::Error> {
fn smoke_test_import_gnomad_genomes_grch38_v3_1() -> Result<(), anyhow::Error> {
let tmp_dir = TempDir::default();
let common = common::cli::Args {
verbose: Verbosity::new(1, 0),
Expand All @@ -552,4 +552,54 @@ mod test {

run(&common, &args)
}

#[test]
fn smoke_test_import_gnomad_exomes_grch38_v4_0() -> Result<(), anyhow::Error> {
let tmp_dir = TempDir::default();
let common = common::cli::Args {
verbose: Verbosity::new(1, 0),
};
let args = Args {
genome_release: common::cli::GenomeRelease::Grch38,
path_in_vcf: vec![String::from(
"tests/gnomad-nuclear/example-exomes-grch38/v4.0/gnomad-exomes.vcf.bgz",
)],
path_out_rocksdb: format!("{}", tmp_dir.join("out-rocksdb").display()),
cf_name: String::from("gnomad_nuclear_data"),
path_wal_dir: None,
tbi_window_size: 1_000_000,
import_fields_json: Some(serde_json::to_string(
&gnomad3::DetailsOptions::with_all_enabled(),
)?),
gnomad_kind: GnomadKind::Exomes,
gnomad_version: String::from("4.0"),
};

run(&common, &args)
}

#[test]
fn smoke_test_import_gnomad_genomes_grch38_v4_0() -> Result<(), anyhow::Error> {
let tmp_dir = TempDir::default();
let common = common::cli::Args {
verbose: Verbosity::new(1, 0),
};
let args = Args {
genome_release: common::cli::GenomeRelease::Grch38,
path_in_vcf: vec![String::from(
"tests/gnomad-nuclear/example-genomes-grch38/v4.0/gnomad-genomes.vcf.bgz",
)],
path_out_rocksdb: format!("{}", tmp_dir.join("out-rocksdb").display()),
cf_name: String::from("gnomad_nuclear_data"),
path_wal_dir: None,
tbi_window_size: 1_000_000,
import_fields_json: Some(serde_json::to_string(
&gnomad3::DetailsOptions::with_all_enabled(),
)?),
gnomad_kind: GnomadKind::Genomes,
gnomad_version: String::from("4.0"),
};

run(&common, &args)
}
}
96 changes: 80 additions & 16 deletions src/gnomad_nuclear/cli/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
// #[case("exomes", "grch38", "4.0")]
fn smoke_query_exomes_all(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_all(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
Expand All @@ -316,15 +317,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_var_single(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_var_single(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
variant: Some(spdi::Var::from_str("GRCh37:1:55516888:G:GA")?),
variant: Some(spdi::Var::from_str(&format!(
"{}:1:55516888:G:GA",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -340,15 +350,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_pos_single(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_pos_single(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
position: Some(spdi::Pos::from_str("GRCh37:1:55516888")?),
position: Some(spdi::Pos::from_str(&format!(
"{}:1:55516888",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -364,15 +383,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_range_find_all_chr1(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_range_find_all_chr1(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
range: Some(spdi::Range::from_str("GRCh37:1:1:249250621")?),
range: Some(spdi::Range::from_str(&format!(
"{}:1:1:249250621",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -388,15 +416,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_range_find_first(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_range_find_first(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
range: Some(spdi::Range::from_str("GRCh37:1:55505599:55505599")?),
range: Some(spdi::Range::from_str(&format!(
"{}:1:55505599:55505599",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -412,15 +449,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_range_find_second(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_range_find_second(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
range: Some(spdi::Range::from_str("GRCh37:1:55505615:55505615")?),
range: Some(spdi::Range::from_str(&format!(
"{}:1:55505615:55505615",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -436,15 +482,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_range_find_none_smaller(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_range_find_none_smaller(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
range: Some(spdi::Range::from_str("GRCh37:1:1:55505598")?),
range: Some(spdi::Range::from_str(&format!(
"{}:1:1:55505598",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand All @@ -460,15 +515,24 @@ mod test {

#[rstest::rstest]
#[case("exomes", "grch37", "2.1")]
fn smoke_query_exomes_range_find_none_larger(
#[case("exomes", "grch38", "4.0")]
#[case("genomes", "grch38", "4.0")]
fn smoke_query_range_find_none_larger(
#[case] kind: &str,
#[case] genome_release: &str,
#[case] version: &str,
) -> Result<(), anyhow::Error> {
crate::common::set_snapshot_suffix!("{}-{}-{}", kind, genome_release, version);
let (common, args, _temp) = build_args(
ArgsQuery {
range: Some(spdi::Range::from_str("GRCh37:1:55516889:249250621")?),
range: Some(spdi::Range::from_str(&format!(
"{}:1:55516889:249250621",
if genome_release == "grch37" {
"GRCh37"
} else {
"GRCh38"
}
))?),
..Default::default()
},
kind,
Expand Down
File renamed without changes.
Loading

0 comments on commit 276f217

Please sign in to comment.