Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: interpret replace_reference condition #49

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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