Skip to content

Commit

Permalink
fix: interpret replace_reference condition (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Mar 22, 2023
1 parent f326e90 commit 8326a55
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/mapper/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ impl Mapper {
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_g)?;
let var_g = self.replace_reference(var_g.clone())?;
let mapper = self.build_alignment_mapper(tx_ac, var_g.accession(), alt_aln_method)?;
if mapper.is_coding_transcript() {
self.g_to_c(&var_g, tx_ac, alt_aln_method)
Expand All @@ -171,7 +170,11 @@ impl Mapper {
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_g)?;
let var_g = self.replace_reference(var_g.clone())?;
let var_g = if self.config.replace_reference {
self.replace_reference(var_g.clone())?
} else {
var_g.clone()
};
if let HgvsVariant::GenomeVariant {
accession,
loc_edit,
Expand Down Expand Up @@ -373,7 +376,11 @@ impl Mapper {
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_g)?;
let var_g = self.replace_reference(var_g.clone())?;
let var_g = if self.config.replace_reference {
self.replace_reference(var_g.clone())?
} else {
var_g.clone()
};
if let HgvsVariant::GenomeVariant {
accession,
gene_symbol,
Expand Down Expand Up @@ -463,7 +470,11 @@ impl Mapper {
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_c)?;
let var_c = self.replace_reference(var_c.clone())?;
let var_c = if self.config.replace_reference {
self.replace_reference(var_c.clone())?
} else {
var_c.clone()
};
if let HgvsVariant::CdsVariant {
accession,
gene_symbol,
Expand Down Expand Up @@ -558,7 +569,11 @@ impl Mapper {
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_t)?;
let var_t = self.replace_reference(var_t.clone())?;
let var_t = if self.config.replace_reference {
self.replace_reference(var_t.clone())?
} else {
var_t.clone()
};
match var_t {
HgvsVariant::TxVariant { .. } => self.n_to_g(&var_t, alt_ac, alt_aln_method),
HgvsVariant::CdsVariant { .. } => self.c_to_g(&var_t, alt_ac, alt_aln_method),
Expand All @@ -579,7 +594,11 @@ impl Mapper {
pub fn c_to_n(&self, var_c: &HgvsVariant) -> Result<HgvsVariant, anyhow::Error> {
log::debug!("c_to_n({})", var_c);
self.validator.validate(var_c)?;
let var_c = self.replace_reference(var_c.clone())?;
let var_c = if self.config.replace_reference {
self.replace_reference(var_c.clone())?
} else {
var_c.clone()
};
if let HgvsVariant::CdsVariant {
accession,
gene_symbol,
Expand Down Expand Up @@ -622,7 +641,11 @@ impl Mapper {
/// * `var_n` -- `HgvsVariant::TxVariant` to project
pub fn n_to_c(&self, var_n: &HgvsVariant) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_n)?;
let var_n = self.replace_reference(var_n.clone())?;
let var_n = if self.config.replace_reference {
self.replace_reference(var_n.clone())?
} else {
var_n.clone()
};
if let HgvsVariant::TxVariant {
accession,
gene_symbol,
Expand Down Expand Up @@ -678,7 +701,11 @@ impl Mapper {
{
self.validator.validate(var_c)?;

let var_c = self.replace_reference(var_c.clone())?;
let var_c = if self.config.replace_reference {
self.replace_reference(var_c.clone())?
} else {
var_c.clone()
};

let reference_data = RefTranscriptData::new(
self.provider.clone(),
Expand Down

0 comments on commit 8326a55

Please sign in to comment.