From 2db5e92316930e76d4b58d47ccc1d2ba2c1010fe Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Wed, 22 Mar 2023 11:50:34 +0100 Subject: [PATCH] feat: improved normalizer configuration (#52) --- src/mapper/variant.rs | 7 +++++-- src/normalizer.rs | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/mapper/variant.rs b/src/mapper/variant.rs index b144a74..bfd4cb5 100644 --- a/src/mapper/variant.rs +++ b/src/mapper/variant.rs @@ -7,7 +7,7 @@ use log::{debug, info}; use super::alignment::{Config as AlignmentConfig, Mapper as AlignmentMapper}; use crate::{ data::interface::Provider, - normalizer::{self, Normalizer}, + normalizer::{self, Config as NormalizerConfig, Normalizer}, parser::{ Accession, CdsInterval, CdsLocEdit, CdsPos, GeneSymbol, GenomeInterval, GenomeLocEdit, HgvsVariant, Mu, NaEdit, TxInterval, TxLocEdit, TxPos, @@ -130,7 +130,10 @@ impl Mapper { self, self.provider.clone(), self.validator.clone(), - Default::default(), + NormalizerConfig { + replace_reference: self.config.replace_reference, + ..Default::default() + }, )) } diff --git a/src/normalizer.rs b/src/normalizer.rs index a27b1f9..668967a 100644 --- a/src/normalizer.rs +++ b/src/normalizer.rs @@ -23,13 +23,14 @@ pub enum Direction { /// Configuration for the normalizer. #[derive(Debug, Clone)] pub struct Config { - alt_aln_method: String, - cross_boundaries: bool, - shuffle_direction: Direction, + pub alt_aln_method: String, + pub cross_boundaries: bool, + pub shuffle_direction: Direction, + pub replace_reference: bool, // TODO: inconsistent with passing in the validator... #[allow(dead_code)] - validate: bool, - window_size: usize, + pub validate: bool, + pub window_size: usize, } impl Default for Config { @@ -38,6 +39,7 @@ impl Default for Config { alt_aln_method: "splign".to_string(), cross_boundaries: false, shuffle_direction: Direction::FiveToThree, + replace_reference: true, validate: true, window_size: 20, } @@ -125,7 +127,11 @@ impl<'a> Normalizer<'a> { // NB: once we support gene conversions, guard against this here as well. - let var = self.mapper.replace_reference(var)?; + let var = if self.config.replace_reference { + self.mapper.replace_reference(var)? + } else { + var + }; // Guard against identity variants. if let Some(na_edit) = var.na_edit() {