Skip to content

Commit

Permalink
fix: cases where dup/inv goes beyond CDS (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Apr 5, 2023
1 parent a5c4a68 commit 5d951b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/mapper/altseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ impl AltSeqBuilder {

let is_frameshift = (end - start) % 3 != 0;

let loc_range = self
.var_c
.loc_range()
.expect("Could not determine insertion location");
let variant_start_aa = ((loc_range.end + 1) as f64 / 3.0).ceil() as i32;
let loc_end = match &self.var_c {
HgvsVariant::CdsVariant { loc_edit, .. } => loc_edit.loc.inner().end.base,
_ => panic!("can only work on CDS variants"),
};
let variant_start_aa = ((loc_end + 1) as f64 / 3.0).ceil() as i32;

AltTranscriptData::new(
&seq,
Expand All @@ -475,12 +475,12 @@ impl AltSeqBuilder {
&seq[end..]
);

let loc_range = self
.var_c
.loc_range()
.expect("Could not determine insertion location");
let variant_start_aa =
std::cmp::max((((loc_range.start + 1) as f64) / 3.0).ceil() as i32, 1);
let loc_start = match &self.var_c {
HgvsVariant::CdsVariant { loc_edit, .. } => loc_edit.loc.inner().start.base,
_ => panic!("can only work on CDS variants"),
};

let variant_start_aa = std::cmp::max(((loc_start as f64) / 3.0).ceil() as i32, 1);

AltTranscriptData::new(
&seq,
Expand Down
2 changes: 1 addition & 1 deletion src/mapper/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ mod test {
assert_eq!(
format!("{}", &crate::parser::NoRef(&actual)),
hgvs_p,
"gene={gene}"
"gene={gene}, hgvs_c={hgvs_c}, hgvs_p={hgvs_p}"
);

Ok(())
Expand Down

0 comments on commit 5d951b1

Please sign in to comment.