diff --git a/exercises/practice/protein-translation/.docs/instructions.md b/exercises/practice/protein-translation/.docs/instructions.md index c211345e..7dc34d2e 100644 --- a/exercises/practice/protein-translation/.docs/instructions.md +++ b/exercises/practice/protein-translation/.docs/instructions.md @@ -11,7 +11,8 @@ Codons: `"AUG", "UUU", "UCU"` Protein: `"Methionine", "Phenylalanine", "Serine"` -There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. If it works for one codon, the program should work for all of them. +There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. +If it works for one codon, the program should work for all of them. However, feel free to expand the list in the test suite to include them all. There are also three terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated. @@ -28,15 +29,17 @@ Note the stop codon `"UAA"` terminates the translation and the final methionine Below are the codons and resulting Amino Acids needed for the exercise. -Codon | Protein -:--- | :--- -AUG | Methionine -UUU, UUC | Phenylalanine -UUA, UUG | Leucine -UCU, UCC, UCA, UCG | Serine -UAU, UAC | Tyrosine -UGU, UGC | Cysteine -UGG | Tryptophan -UAA, UAG, UGA | STOP - -Learn more about [protein translation on Wikipedia](http://en.wikipedia.org/wiki/Translation_(biology)) +| Codon | Protein | +| :----------------- | :------------ | +| AUG | Methionine | +| UUU, UUC | Phenylalanine | +| UUA, UUG | Leucine | +| UCU, UCC, UCA, UCG | Serine | +| UAU, UAC | Tyrosine | +| UGU, UGC | Cysteine | +| UGG | Tryptophan | +| UAA, UAG, UGA | STOP | + +Learn more about [protein translation on Wikipedia][protein-translation]. + +[protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology) diff --git a/exercises/practice/protein-translation/.meta/tests.toml b/exercises/practice/protein-translation/.meta/tests.toml index 02a54c34..10ee1eee 100644 --- a/exercises/practice/protein-translation/.meta/tests.toml +++ b/exercises/practice/protein-translation/.meta/tests.toml @@ -1,6 +1,16 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[2c44f7bf-ba20-43f7-a3bf-f2219c0c3f98] +description = "Empty RNA sequence results in no proteins" [96d3d44f-34a2-4db4-84cd-fff523e069be] description = "Methionine RNA sequence" @@ -53,6 +63,12 @@ description = "STOP codon RNA sequence 2" [9c2ad527-ebc9-4ace-808b-2b6447cb54cb] description = "STOP codon RNA sequence 3" +[f4d9d8ee-00a8-47bf-a1e3-1641d4428e54] +description = "Sequence of two protein codons translates into proteins" + +[dd22eef3-b4f1-4ad6-bb0b-27093c090a9d] +description = "Sequence of two different protein codons translates into proteins" + [d0f295df-fb70-425c-946c-ec2ec185388e] description = "Translate RNA strand into correct protein list" @@ -70,3 +86,22 @@ description = "Translation stops if STOP codon in middle of three-codon sequence [2c2a2a60-401f-4a80-b977-e0715b23b93d] description = "Translation stops if STOP codon in middle of six-codon sequence" + +[f6f92714-769f-4187-9524-e353e8a41a80] +description = "Sequence of two non-STOP codons does not translate to a STOP codon" + +[1e75ea2a-f907-4994-ae5c-118632a1cb0f] +description = "Non-existing codon can't translate" +include = false + +[9eac93f3-627a-4c90-8653-6d0a0595bc6f] +description = "Unknown amino acids, not part of a codon, can't translate" +reimplements = "1e75ea2a-f907-4994-ae5c-118632a1cb0f" +include = false + +[9d73899f-e68e-4291-b1e2-7bf87c00f024] +description = "Incomplete RNA sequence can't translate" +include = false + +[43945cf7-9968-402d-ab9f-b8a28750b050] +description = "Incomplete RNA sequence can translate if valid until a STOP codon" diff --git a/exercises/practice/protein-translation/test/protein_translation_test.clj b/exercises/practice/protein-translation/test/protein_translation_test.clj index 05981ed0..2b25c7b3 100644 --- a/exercises/practice/protein-translation/test/protein_translation_test.clj +++ b/exercises/practice/protein-translation/test/protein_translation_test.clj @@ -1,36 +1,138 @@ (ns protein-translation-test - (:require [clojure.test :refer [deftest is are]] + (:require [clojure.test :refer [deftest testing is]] protein-translation)) -(deftest AUG-translates-to-Methionine - (is (= "Methionine" (protein-translation/translate-codon "AUG")))) +(deftest empty-rna-sequence-results-in-no-protein + (testing "Empty RNA sequence results in no protein" + (is (= [] (protein-translation/translate-rna ""))))) -(deftest UGG-translates-to-Tryptophan - (is (= "Tryptophan" (protein-translation/translate-codon "UGG")))) +(deftest methionine-RNA-sequence + (testing "Methionine RNA sequence" + (is (= ["Methionine"] + (protein-translation/translate-rna "AUG"))))) -(deftest identifies-Phenylalanine-codons - (are [codon] (= "Phenylalanine" (protein-translation/translate-codon codon)) "UUU" "UUC")) +(deftest phenylalanine-RNA-sequence-1 + (testing "Phenylalanine RNA sequence 1" + (is (= ["Phenylalanine"] + (protein-translation/translate-rna "UUU"))))) -(deftest identifies-Leucine-codons - (are [codon] (= "Leucine" (protein-translation/translate-codon codon)) "UUA" "UUG")) +(deftest phenylalanine-RNA-sequence-2 + (testing "Phenylalanine RNA sequence 2" + (is (= ["Phenylalanine"] + (protein-translation/translate-rna "UUC"))))) -(deftest identiefies-Serine-codons - (are [codon] (= "Serine" (protein-translation/translate-codon codon)) "UCU" "UCC" "UCA" "UCG")) +(deftest leucine-RNA-sequence-1 + (testing "Leucine RNA sequence 1" + (is (= ["Leucine"] + (protein-translation/translate-rna "UUA"))))) -(deftest identiefies-Tyrosine-codons - (are [codon] (= "Tyrosine" (protein-translation/translate-codon codon)) "UAU" "UAC")) +(deftest leucine-RNA-sequence-2 + (testing "Leucine RNA sequence 2" + (is (= ["Leucine"] + (protein-translation/translate-rna "UUG"))))) -(deftest identifies-Cysteine-codons - (are [codon] (= "Cysteine" (protein-translation/translate-codon codon)) "UGU" "UGC")) +(deftest serine-RNA-sequence-1 + (testing "Serine RNA sequence 1" + (is (= ["Serine"] + (protein-translation/translate-rna "UCU"))))) -(deftest identifies-stop-codons - (are [codon] (= "STOP" (protein-translation/translate-codon codon)) "UAA" "UAG" "UGA")) +(deftest serine-RNA-sequence-2 + (testing "Serine RNA sequence 2" + (is (= ["Serine"] + (protein-translation/translate-rna "UCC"))))) -(deftest translates-rna-strand-into-correct-protein - (is (= ["Methionine" "Phenylalanine" "Tryptophan"] (protein-translation/translate-rna "AUGUUUUGG")))) +(deftest serine-RNA-sequence-3 + (testing "Serine RNA sequence 3" + (is (= ["Serine"] + (protein-translation/translate-rna "UCA"))))) -(deftest stops-translation-if-stop-codon-present - (is (= ["Methionine" "Phenylalanine"] (protein-translation/translate-rna "AUGUUUUAA")))) +(deftest serine-RNA-sequence-4 + (testing "Serine RNA sequence 4" + (is (= ["Serine"] + (protein-translation/translate-rna "UCG"))))) -(deftest stops-translation-of-longer-strand - (is (= ["Tryptophan" "Cysteine" "Tyrosine"] (protein-translation/translate-rna "UGGUGUUAUUAAUGGUUU")))) +(deftest tyrosine-RNA-sequence-1 + (testing "Tyrosine RNA sequence 1" + (is (= ["Tyrosine"] + (protein-translation/translate-rna "UAU"))))) + +(deftest tyrosine-RNA-sequence-2 + (testing "Tyrosine RNA sequence 2" + (is (= ["Tyrosine"] + (protein-translation/translate-rna "UAC"))))) + +(deftest cysteine-RNA-sequence-1 + (testing "Cysteine RNA sequence 1" + (is (= ["Cysteine"] + (protein-translation/translate-rna "UGU"))))) + +(deftest cysteine-RNA-sequence-2 + (testing "Cysteine RNA sequence 2" + (is (= ["Cysteine"] + (protein-translation/translate-rna "UGC"))))) + +(deftest tryptophan-RNA-sequence + (testing "Tryptophan RNA sequence" + (is (= ["Tryptophan"] + (protein-translation/translate-rna "UGG"))))) + +(deftest STOP-codon-RNA-sequence-1 + (testing "STOP codon RNA sequence 1" + (is (= [] (protein-translation/translate-rna "UAA"))))) + +(deftest STOP-codon-RNA-sequence-2 + (testing "STOP codon RNA sequence 2" + (is (= [] (protein-translation/translate-rna "UAG"))))) + +(deftest STOP-codon-RNA-sequence-3 + (testing "STOP codon RNA sequence 3" + (is (= [] (protein-translation/translate-rna "UGA"))))) + +(deftest sequence-of-two-protein-codons-translates-into-proteins + (testing "Sequence of two protein codons translates into proteins" + (is (= ["Phenylalanine", "Phenylalanine"] + (protein-translation/translate-rna "UUUUUU"))))) + +(deftest sequence-of-two-different-protein-codons-translates-into-proteins + (testing "Sequence of two different protein codons translates into proteins" + (is (= ["Leucine", "Leucine"] + (protein-translation/translate-rna "UUAUUG"))))) + +(deftest translate-RNA-strand-into-correct-protein-list + (testing "Translate RNA strand into correct protein list" + (is (= ["Methionine", "Phenylalanine", "Tryptophan"] + (protein-translation/translate-rna "AUGUUUUGG"))))) + +(deftest translation-stops-if-STOP-codon-at-beginning-of-sequence + (testing "Translation stops if STOP codon at beginning of sequence" + (is (= [] (protein-translation/translate-rna "UAGUGG"))))) + +(deftest translation-stops-if-STOP-codon-at-end-of-two-codon-sequence + (testing "Translation stops if STOP codon at end of two-codon sequence" + (is (= ["Tryptophan"] + (protein-translation/translate-rna "UGGUAG"))))) + +(deftest translation-stops-if-STOP-codon-at-end-of-three-codon-sequence + (testing "Translation stops if STOP codon at end of three-codon sequence" + (is (= ["Methionine", "Phenylalanine"] + (protein-translation/translate-rna "AUGUUUUAA"))))) + +(deftest translation-stops-if-STOP-codon-in-middle-of-three-codon-sequence + (testing "Translation stops if STOP codon in middle of three-codon sequence" + (is (= ["Tryptophan"] + (protein-translation/translate-rna "UGGUAGUGG"))))) + +(deftest translation-stops-if-STOP-codon-in-middle-of-six-codon-sequence + (testing "Translation stops if STOP codon in middle of six-codon sequence" + (is (= ["Tryptophan", "Cysteine", "Tyrosine"] + (protein-translation/translate-rna "UGGUGUUAUUAAUGGUUU"))))) + +(deftest sequence-of-two-non-STOP-codons-does-not-translate-to-a-STOP-codon + (testing "Sequence of two non-STOP codons does not translate to a STOP codon" + (is (= ["Methionine", "Methionine"] + (protein-translation/translate-rna "AUGAUG"))))) + +(deftest incomplete-RNA-sequence-can-translate-if-valid-until-a-STOP-codon + (testing "Incomplete RNA sequence can translate if valid until a STOP codon" + (is (= ["Phenylalanine", "Phenylalanine"] + (protein-translation/translate-rna "UUCUUCUAAUGGU")))))