diff --git a/src/annotate/seqvars/mod.rs b/src/annotate/seqvars/mod.rs index d20b24f2..9fa42ecf 100644 --- a/src/annotate/seqvars/mod.rs +++ b/src/annotate/seqvars/mod.rs @@ -812,7 +812,12 @@ impl VarFishSeqvarTsvWriter { None => Ok(-1), // cf. https://github.com/zaeleus/noodles/issues/164 // _ => anyhow::bail!(format!("invalid GQ value {:?} in {:#?}", value, sample)), - _ => anyhow::bail!(format!("invalid GQ value {:?}", value)), + _ => anyhow::bail!(format!( + "invalid GQ value {:?} at {:?}:{:?}", + value, + record.chromosome(), + record.position() + )), }) .transpose()? { @@ -823,10 +828,21 @@ impl VarFishSeqvarTsvWriter { .get(&key::Key::from_str("SQ")?) .map(|value| match value { Some(sample::Value::Float(f)) => Ok(*f), + Some(sample::Value::Array(sample::value::Array::Float(f))) => { + Ok(f[0].expect("SQ should be a single float value")) + } None => Ok(-1.0), // cf. https://github.com/zaeleus/noodles/issues/164 // _ => anyhow::bail!(format!("invalid GQ value {:?} in {:#?}", value, sample)), - _ => anyhow::bail!(format!("invalid GQ value {:?}", value)), + // _ => anyhow::bail!(format!("invalid GQ value {:?}", value)), + _ => { + anyhow::bail!(format!( + "invalid SQ value {:?} at {:?}:{:?}", + value, + record.chromosome(), + record.position() + )) + } }) .transpose()? { @@ -1699,4 +1715,39 @@ mod test { Ok(()) } + + /// Mitochondnrial variants called by the DRAGEN v310 germline caller have special format + /// considerations. + /// + /// See: https://support-docs.illumina.com/SW/DRAGEN_v310/Content/SW/DRAGEN/MitochondrialCalling.htm + #[test] + fn test_dragen_mitochondrial_variant() -> Result<(), anyhow::Error> { + let temp = TempDir::default(); + let path_out = temp.join("output.tsv"); + + let args_common = crate::common::Args { + verbose: Verbosity::new(0, 1), + }; + let args = Args { + genome_release: None, + path_db: String::from("tests/data/annotate/db"), + path_input_vcf: String::from("tests/data/db/create/mitochondrial_variants.vcf"), + output: PathOutput { + path_output_vcf: None, + path_output_tsv: Some(path_out.into_os_string().into_string().unwrap()), + }, + max_var_count: None, + path_input_ped: Some(String::from( + "tests/data/db/create/mitochondrial_variants.ped", + )), + }; + + run(&args_common, &args)?; + + let actual = std::fs::read_to_string(args.output.path_output_tsv.unwrap())?; + let expected = std::fs::read_to_string("tests/data/db/create/mitochondrial_variants.tsv")?; + assert_eq!(&expected, &actual); + + Ok(()) + } } diff --git a/tests/data/db/create/mitochondrial_variants.ped b/tests/data/db/create/mitochondrial_variants.ped new file mode 100644 index 00000000..90d1f727 --- /dev/null +++ b/tests/data/db/create/mitochondrial_variants.ped @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6a175f650923802a94c81637b8cfec56d0f0147a2c7c3a687dd01820a1d7eba +size 80 diff --git a/tests/data/db/create/mitochondrial_variants.tsv b/tests/data/db/create/mitochondrial_variants.tsv new file mode 100644 index 00000000..ab518d5f --- /dev/null +++ b/tests/data/db/create/mitochondrial_variants.tsv @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e6cdf931d8d0787d3a9a75db79f7e90eb8d85b51bcbbd95e1a5415205dbc9ae +size 1145 diff --git a/tests/data/db/create/mitochondrial_variants.vcf b/tests/data/db/create/mitochondrial_variants.vcf new file mode 100644 index 00000000..1d2b455b --- /dev/null +++ b/tests/data/db/create/mitochondrial_variants.vcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0758e03e92a8a11b2853a2c51d618a0b63215e6a7c91fd9ca0b56d7236431b3 +size 9601