Skip to content

Commit

Permalink
fix: Allow '.' genotypes (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiamaz authored Sep 18, 2023
1 parent 34b540c commit 6d0c5b8
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/annotate/seqvars/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,14 +711,10 @@ impl VarFishSeqvarTsvWriter {
..Default::default()
};

if let Some(gt) = sample
.get(&GENOTYPE)
.map(|value| match value {
Some(sample::Value::String(s)) => Ok(s.to_owned()),
_ => anyhow::bail!("invalid GT value"),
})
.transpose()?
{
if let Some(gt) = sample.get(&GENOTYPE).map(|value| match value {
Some(sample::Value::String(s)) => s.to_owned(),
_ => ".".into(),
}) {
let individual = self
.pedigree
.as_ref()
Expand Down Expand Up @@ -1672,4 +1668,35 @@ mod test {

Ok(())
}

#[test]
fn test_badly_formed_vcf_entry() -> 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/badly_formed_vcf_entry.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/badly_formed_vcf_entry.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/badly_formed_vcf_entry.tsv")?;
assert_eq!(&expected, &actual);

Ok(())
}
}
3 changes: 3 additions & 0 deletions tests/data/db/create/badly_formed_vcf_entry.ped
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/data/db/create/badly_formed_vcf_entry.tsv
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/data/db/create/badly_formed_vcf_entry.vcf
Git LFS file not shown

0 comments on commit 6d0c5b8

Please sign in to comment.