Skip to content

Commit

Permalink
fix: add variant region condition for dups ending in 3' UTR (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Jul 25, 2024
1 parent bc73036 commit 9e48cbe
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ postgres = { version = "0.19", features = ["with-chrono-0_4"] }
quick_cache = "0.6"
regex = "1.7"
rustc-hash = "2.0"
seqrepo = { version = "0.10.2", features = ["cached"] }
seqrepo = { version = "0.10.3", features = ["cached"] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
Expand Down
8 changes: 7 additions & 1 deletion src/mapper/altseq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,13 @@ impl AltSeqBuilder {
match &self.var_c {
HgvsVariant::CdsVariant { loc_edit, .. } => {
let loc = loc_edit.loc.inner();
if loc.start.cds_from == CdsFrom::End && loc.end.cds_from == CdsFrom::End {
let edit = loc_edit.edit.inner();
#[allow(clippy::nonminimal_bool)]
if loc.start.cds_from == CdsFrom::End && loc.end.cds_from == CdsFrom::End
|| ((edit.is_ins() || edit.is_dup()) && loc.end.cds_from == CdsFrom::End)
{
// 3' UTR if both ends are 3' UTR or if the variant is an insertion/duplication
// and the end is 3' UTR.
VariantLocation::ThreePrimeUtr
} else if loc.start.base < 0 && loc.end.base < 0 {
VariantLocation::FivePrimeUtr
Expand Down
42 changes: 41 additions & 1 deletion src/mapper/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,28 @@ mod test {
Ok(())
}

#[test]
fn map_of_ins_three_prime_utr() -> Result<(), Error> {
let mapper = build_mapper()?;
let hgvs_c = "NM_004985.4:c.567_*1insCCC"; // gene KRAS
let var_c = HgvsVariant::from_str(hgvs_c)?;
let var_p = mapper.c_to_p(&var_c, None)?;
assert_eq!(format!("{}", &var_p), "NP_004976.2:p.?");

Ok(())
}

#[test]
fn map_of_dup_three_prime_utr() -> Result<(), Error> {
let mapper = build_mapper()?;
let hgvs_c = "NM_153223.3:c.2959_*1dup"; // gene CEP120
let var_c = HgvsVariant::from_str(hgvs_c)?;
let var_p = mapper.c_to_p(&var_c, None)?;
assert_eq!(format!("{}", &var_p), "NP_694955.2:p.?");

Ok(())
}

// TODO(#17): Need to implement validation.
// #[test]
// fn map_of_c_out_of_reference_bound() -> Result<(), Error> {
Expand Down Expand Up @@ -1622,14 +1644,32 @@ mod test {
}

#[test]
fn hgvs_c_to_p_three_prime_utr() -> Result<(), Error> {
fn hgvs_c_to_p_sub_three_prime_ut() -> Result<(), Error> {
let hgvsc = "NM_999999.1:c.*3G>A";
let hgvsp_expected = "MOCK:p.?";
test_hgvs_c_to_p_conversion(hgvsc, hgvsp_expected)?;

Ok(())
}

#[test]
fn hgvs_c_to_p_ins_three_prime_utr() -> Result<(), Error> {
let hgvsc = "NM_999999.1:c.39_*1insA";
let hgvsp_expected = "MOCK:p.?";
test_hgvs_c_to_p_conversion(hgvsc, hgvsp_expected)?;

Ok(())
}

#[test]
fn hgvs_c_to_p_dup_three_prime_utr() -> Result<(), Error> {
let hgvsc = "NM_999999.1:c.12_*1dup";
let hgvsp_expected = "MOCK:p.?";
test_hgvs_c_to_p_conversion(hgvsc, hgvsp_expected)?;

Ok(())
}

#[test]
fn hgvs_c_to_p_deletion_into_three_prime_utr_frameshift() -> Result<(), Error> {
let hgvsc = "NM_999999.1:c.27_*3del";
Expand Down
10 changes: 10 additions & 0 deletions src/parser/ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ impl NaEdit {
}
}

/// Returns whether the edit is an insertion.
pub fn is_ins(&self) -> bool {
matches!(self, NaEdit::Ins { .. })
}

/// Returns whether the edit is a duplication.
pub fn is_dup(&self) -> bool {
matches!(self, NaEdit::Dup { .. })
}

/// Ensures that the reference is a count and no reference bases.
pub fn with_num(&self) -> Self {
match self {
Expand Down
4 changes: 2 additions & 2 deletions tests/data/seqrepo_cache.fasta
Git LFS file not shown

0 comments on commit 9e48cbe

Please sign in to comment.