diff --git a/src/mapper/variant.rs b/src/mapper/variant.rs index 0d36066..4681866 100644 --- a/src/mapper/variant.rs +++ b/src/mapper/variant.rs @@ -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 { - 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) } } diff --git a/tests/data/data/bootstrap.sh b/tests/data/data/bootstrap.sh index ce0c3ca..14be387 100644 --- a/tests/data/data/bootstrap.sh +++ b/tests/data/data/bootstrap.sh @@ -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 ------------------------------------------------------------