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

Incorrect translation for unaffected stop codon #86

Merged
merged 1 commit into from
Jan 15, 2024
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
47 changes: 27 additions & 20 deletions src/varity/vcf_to_hgvs/protein.clj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@
alt-positions (set (range pos (+ pos (count ref))))]
(boolean (seq (s/intersection ter-site-positions alt-positions)))))

(defn- ter-site-same-pos?
[ref-prot-seq alt-prot-seq]
(let [ter-site-pos (dec (count ref-prot-seq))]
(= \* (get alt-prot-seq ter-site-pos))))

(defn- apply-offset
[pos ref alt exon-ranges ref-include-ter-site pos*]
(letfn [(apply-offset* [exon-ranges*]
Expand Down Expand Up @@ -426,26 +431,28 @@
(coord/unknown-coordinate))))))

(defn- protein-extension
[ppos pref palt seq-info]
(let [{:keys [alt-prot-seq alt-tx-prot-seq ini-offset]} seq-info
[_ ins offset _] (diff-bases pref palt)
rest-seq (if (= ppos 1)
(-> alt-tx-prot-seq
(subs 0 ini-offset)
reverse
(#(apply str %)))
(-> alt-tx-prot-seq
(subs (+ ini-offset (count alt-prot-seq)))))
ter-site (some-> (string/index-of rest-seq (if (= ppos 1) "M" "*")) inc)]
(mut/protein-extension (if (= ppos 1) "Met" "Ter")
(coord/protein-coordinate (if (= ppos 1) 1 (+ ppos offset)))
(mut/->long-amino-acid (if (= ppos 1)
(last ins)
(or (last ins) (first rest-seq))))
(if (= ppos 1) :upstream :downstream)
(if ter-site
(coord/protein-coordinate ter-site)
(coord/unknown-coordinate)))))
[ppos pref palt {:keys [ref-prot-seq alt-prot-seq alt-tx-prot-seq c-ter-adjusted-alt-prot-seq ini-offset]}]
(if (and (not= ppos 1)
(ter-site-same-pos? ref-prot-seq c-ter-adjusted-alt-prot-seq))
(mut/protein-no-effect)
Comment on lines +434 to +437
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this function, I added line 435-437 and moved seq-info destructuring to args .
And I just fixed indent of following lines.

(let [[_ ins offset _] (diff-bases pref palt)
rest-seq (if (= ppos 1)
(-> alt-tx-prot-seq
(subs 0 ini-offset)
reverse
(#(apply str %)))
(-> alt-tx-prot-seq
(subs (+ ini-offset (count alt-prot-seq)))))
ter-site (some-> (string/index-of rest-seq (if (= ppos 1) "M" "*")) inc)]
(mut/protein-extension (if (= ppos 1) "Met" "Ter")
(coord/protein-coordinate (if (= ppos 1) 1 (+ ppos offset)))
(mut/->long-amino-acid (if (= ppos 1)
(last ins)
(or (last ins) (first rest-seq))))
(if (= ppos 1) :upstream :downstream)
(if ter-site
(coord/protein-coordinate ter-site)
(coord/unknown-coordinate))))))

(defn- mutation
[seq-rdr rg pos ref alt options]
Expand Down
7 changes: 7 additions & 0 deletions test/varity/vcf_to_hgvs/protein_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@
[15 20] 15
[5 10] 5)))

(deftest ter-site-same-pos?-test
(are [p ref alt] (p (#'prot/ter-site-same-pos? ref alt))
true? "MTGA*" "MTGA*"
true? "MTGA*" "MTGA*CT"
false? "MTGA*" "MTGAQCT*"
false? "MTGA*" "MTGA"))

(deftest apply-offset-test
(let [pos 100
ref "GCTGACC"
Expand Down
1 change: 1 addition & 0 deletions test/varity/vcf_to_hgvs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
"chr7" 55181876 "A" "T" '("p.=") ; not actual example (+)
"chr7" 55181874 "TGAT" "T" '("p.=") ; not actual example (+)
"chr7" 55181876 "A" "AGGT" '("p.=") ; not actual example (+)
"chr3" 149520808 "C" "CTTAA" '("p.=") ; not actual example (-)

;; unknown
"chr12" 40393453 "G" "A" '("p.?") ; not actual example (+)
Expand Down