Skip to content

Commit

Permalink
feat: improved normalizer configuration (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Mar 22, 2023
1 parent f1536b9 commit 2db5e92
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/mapper/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -130,7 +130,10 @@ impl Mapper {
self,
self.provider.clone(),
self.validator.clone(),
Default::default(),
NormalizerConfig {
replace_reference: self.config.replace_reference,
..Default::default()
},
))
}

Expand Down
18 changes: 12 additions & 6 deletions src/normalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 2db5e92

Please sign in to comment.