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: add variant region condition for dups ending in 3' UTR (#192) #195

Merged
Show file tree
Hide file tree
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
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 @@
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 @@
}

#[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 Expand Up @@ -1759,7 +1799,7 @@
pub hgvs_c: String,
#[serde(alias = "HGVSp")]
pub hgvs_p: Option<String>,
pub description: Option<String>,

Check warning on line 1802 in src/mapper/variant.rs

View workflow job for this annotation

GitHub Actions / Testing (full)

fields `description` and `alternatives` are never read
pub alternatives: Option<String>,
}

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
8 changes: 5 additions & 3 deletions tests/data/data/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ ADRB2
AGBL5
AKR1C3
ALG9
ALMS1
AOAH
ASB18
ALMS1
ATM
BAHCC1
BOLA3
Expand All @@ -80,6 +80,7 @@ BRCA2
C18orf32
CACNA1S
CCNQ
CEP120
COL1A1
COL3A1
DEFB133
Expand All @@ -95,15 +96,16 @@ FBN1
FBXO22
FOLR3
GTF3C2
HIST3H2A
H2AW
HELQ
HEXB
HIST3H2A
HMGA1
IFNA16
IRAK3
JRK
KCNIP4
KRAS
L1CAM
LCE2B
LCE3C
Expand All @@ -115,8 +117,8 @@ MED21
MLH1
MSH6
MYH7
NR1H2
NEFL
NR1H2
OMA1
OPA1
OR9A4
Expand Down
4 changes: 2 additions & 2 deletions tests/data/data/uta_20210129-subset.pgd.gz
Git LFS file not shown
4 changes: 2 additions & 2 deletions tests/data/seqrepo_cache.fasta
Git LFS file not shown
Loading