Skip to content

Commit

Permalink
fix: variant mapper g_to_t used wrong logic (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Mar 2, 2023
1 parent 7f925c8 commit 040e2d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
22 changes: 9 additions & 13 deletions src/mapper/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,17 @@ impl Mapper {
/// * `alt_al_method` -- alignment method, e.g., `splign`
pub fn g_to_t(
&self,
var_t: &HgvsVariant,
alt_ac: &str,
var_g: &HgvsVariant,
tx_ac: &str,
alt_aln_method: &str,
) -> Result<HgvsVariant, anyhow::Error> {
self.validator.validate(var_t)?;
let var_t = self.replace_reference(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),
_ => {
return Err(anyhow::anyhow!(
"Expected transcript or CDS variant but received {}",
&var_t
))
}
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)
} else {
self.g_to_n(&var_g, tx_ac, alt_aln_method)
}
}

Expand Down
16 changes: 6 additions & 10 deletions tests/data/data/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ psql-uta()

pg-list()
{
result=""
while [[ $# -ne 0 ]]; do
if [[ ! -z "${result}" ]]; then
result="${result}, "
fi
result="${result}'$1'"
shift
done
result="(${result})"
echo $result
echo $* \
| tr ' ' '\n' \
| sed -e "s/^/'/g" -e "s/$/'/g" \
| tr '\n' ',' \
| sed -e 's/,$//g' \
| sed -e "s/^/(/g" -e "s/$/)/g"
}

# Initialization ------------------------------------------------------------
Expand Down

0 comments on commit 040e2d3

Please sign in to comment.