Skip to content

Commit

Permalink
fix: work around issue with glnexus #362
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Feb 22, 2024
1 parent f4808fe commit f5f1834
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 88 deletions.
64 changes: 0 additions & 64 deletions misc/fix_glnexus.py

This file was deleted.

41 changes: 24 additions & 17 deletions src/annotate/seqvars/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use annonars::common::keys;
use annonars::freqs::cli::import::reading::guess_assembly;
use annonars::freqs::serialized::{auto, mt, xy};
use anyhow::anyhow;
use noodles_vcf::header::record::value::map::format::Type as FormatType;
use noodles_vcf::record::genotypes::keys::key::{
self, CONDITIONAL_GENOTYPE_QUALITY, GENOTYPE, READ_DEPTH, READ_DEPTHS,
};
Expand All @@ -31,7 +32,7 @@ use flate2::write::GzEncoder;
use flate2::Compression;
use noodles_bgzf::Writer as BgzfWriter;
use noodles_vcf::header::{
record::value::map::{info::Type, Info},
record::value::map::{info::Type as InfoType, Info},
Number,
};
use noodles_vcf::reader::Builder as VariantReaderBuilder;
Expand Down Expand Up @@ -128,31 +129,31 @@ fn build_header(header_in: &VcfHeader) -> VcfHeader {
field::Key::from_str("gnomad_exomes_an").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of alleles in gnomAD exomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_exomes_hom").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of hom. alt. carriers in gnomAD exomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_exomes_het").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of het. alt. carriers in gnomAD exomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_exomes_hemi").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of hemi. alt. carriers in gnomAD exomes",
),
);
Expand All @@ -161,31 +162,31 @@ fn build_header(header_in: &VcfHeader) -> VcfHeader {
field::Key::from_str("gnomad_genomes_an").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of alleles in gnomAD genomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_genomes_hom").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of hom. alt. carriers in gnomAD genomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_genomes_het").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of het. alt. carriers in gnomAD genomes",
),
);
header_out.infos_mut().insert(
field::Key::from_str("gnomad_genomes_hemi").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of hemi. alt. carriers in gnomAD genomes",
),
);
Expand All @@ -194,23 +195,23 @@ fn build_header(header_in: &VcfHeader) -> VcfHeader {
field::Key::from_str("helix_an").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of alleles in HelixMtDb",
),
);
header_out.infos_mut().insert(
field::Key::from_str("helix_hom").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of hom. alt. carriers in HelixMtDb",
),
);
header_out.infos_mut().insert(
field::Key::from_str("helix_het").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::Integer,
InfoType::Integer,
"Number of het. alt. carriers in HelixMtDb",
),
);
Expand All @@ -219,7 +220,7 @@ fn build_header(header_in: &VcfHeader) -> VcfHeader {
field::Key::from_str("ANN").unwrap(),
Map::<Info>::new(
Number::Unknown,
Type::String,
InfoType::String,
"Functional annotations: 'Allele | Annotation | Annotation_Impact | Gene_Name | \
Gene_ID | Feature_Type | Feature_ID | Transcript_BioType | Rank | HGVS.c | HGVS.p | \
cDNA.pos / cDNA.length | CDS.pos / CDS.length | AA.pos / AA.length | Distance | \
Expand All @@ -231,21 +232,21 @@ fn build_header(header_in: &VcfHeader) -> VcfHeader {
field::Key::from_str("clinvar_clinsig").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::String,
InfoType::String,
"ClinVar clinical significance (one highest significance per VCV)",
),
);
header_out.infos_mut().insert(
field::Key::from_str("clinvar_rcv").unwrap(),
Map::<Info>::new(
Number::Count(1),
Type::String,
InfoType::String,
"ClinVar RCV accession (corresponds to clinvar_clinsig)",
),
);
header_out.infos_mut().insert(
field::Key::from_str("clinvar_vcv").unwrap(),
Map::<Info>::new(Number::Count(1), Type::String, "ClinVar VCV accession"),
Map::<Info>::new(Number::Count(1), InfoType::String, "ClinVar VCV accession"),
);

header_out
Expand Down Expand Up @@ -1416,9 +1417,15 @@ impl AnnotatedVcfWriter for VarFishSeqvarTsvWriter {
fn run_with_writer(writer: &mut dyn AnnotatedVcfWriter, args: &Args) -> Result<(), anyhow::Error> {
tracing::info!("Open VCF and read header");
let mut reader = VariantReaderBuilder::default().build_from_path(&args.path_input_vcf)?;
let header_in = reader.read_header()?;
let mut header_in = reader.read_header()?;
let header_out = build_header(&header_in);

// Work around glnexus issue with RNC.
if let Some(format) = header_in.formats_mut().get_mut("RNC") {
*format.number_mut() = Number::Count(1);
*format.type_mut() = FormatType::String;
}

// Guess genome release from contigs in VCF header.
let genome_release = args.genome_release.map(|gr| match gr {
GenomeRelease::Grch37 => Assembly::Grch37p10, // has chrMT!
Expand Down
Git LFS file not shown
3 changes: 0 additions & 3 deletions tests/data/annotate/seqvars/clair3-glnexus-min.original.vcf

This file was deleted.

4 changes: 2 additions & 2 deletions tests/data/annotate/seqvars/clair3-glnexus-min.vcf
Git LFS file not shown

0 comments on commit f5f1834

Please sign in to comment.