-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
exercises/practice/protein-translation/.docs/instructions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Instructions | ||
|
||
Translate RNA sequences into proteins. | ||
|
||
RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: | ||
|
||
RNA: `"AUGUUUUCU"` => translates to | ||
|
||
Codons: `"AUG", "UUU", "UCU"` | ||
=> which become a polypeptide with the following sequence => | ||
|
||
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. | ||
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. | ||
|
||
All subsequent codons after are ignored, like this: | ||
|
||
RNA: `"AUGUUUUCUUAAAUG"` => | ||
|
||
Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` => | ||
|
||
Protein: `"Methionine", "Phenylalanine", "Serine"` | ||
|
||
Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence. | ||
|
||
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][protein-translation]. | ||
|
||
[protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"authors": [ | ||
"BNAndras" | ||
], | ||
"files": { | ||
"solution": [ | ||
"src/ProteinTranslation.elm" | ||
], | ||
"test": [ | ||
"tests/Tests.elm" | ||
], | ||
"example": [ | ||
".meta/src/ProteinTranslation.example.elm" | ||
] | ||
}, | ||
"blurb": "Translate RNA sequences into proteins.", | ||
"source": "Tyler Long" | ||
} |
104 changes: 104 additions & 0 deletions
104
exercises/practice/protein-translation/.meta/src/ProteinTranslation.example.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
module ProteinTranslation exposing (proteins) | ||
|
||
import List | ||
import String | ||
|
||
|
||
proteins : String -> Result String (List String) | ||
proteins strand = | ||
case splitIntoCodons strand of | ||
[ "" ] -> | ||
Ok [] | ||
|
||
codons -> | ||
case processCodons [] codons of | ||
Ok results -> | ||
Ok (List.reverse results) | ||
|
||
Err err -> | ||
Err err | ||
|
||
|
||
splitIntoCodons : String -> List String | ||
splitIntoCodons strand = | ||
if String.length strand > 3 then | ||
String.left 3 strand :: splitIntoCodons (String.dropLeft 3 strand) | ||
|
||
else | ||
[ strand ] | ||
|
||
|
||
processCodons : List String -> List String -> Result String (List String) | ||
processCodons acc codons = | ||
case codons of | ||
[] -> | ||
Ok acc | ||
|
||
codon :: rest -> | ||
case codonToProtein codon of | ||
Ok "STOP" -> | ||
Ok acc | ||
|
||
Ok protein -> | ||
processCodons (protein :: acc) rest | ||
|
||
Err err -> | ||
Err err | ||
|
||
|
||
codonToProtein : String -> Result String String | ||
codonToProtein codon = | ||
case codon of | ||
"AUG" -> | ||
Ok "Methionine" | ||
|
||
"UUU" -> | ||
Ok "Phenylalanine" | ||
|
||
"UUC" -> | ||
Ok "Phenylalanine" | ||
|
||
"UUA" -> | ||
Ok "Leucine" | ||
|
||
"UUG" -> | ||
Ok "Leucine" | ||
|
||
"UCU" -> | ||
Ok "Serine" | ||
|
||
"UCC" -> | ||
Ok "Serine" | ||
|
||
"UCA" -> | ||
Ok "Serine" | ||
|
||
"UCG" -> | ||
Ok "Serine" | ||
|
||
"UAU" -> | ||
Ok "Tyrosine" | ||
|
||
"UAC" -> | ||
Ok "Tyrosine" | ||
|
||
"UGU" -> | ||
Ok "Cysteine" | ||
|
||
"UGC" -> | ||
Ok "Cysteine" | ||
|
||
"UGG" -> | ||
Ok "Tryptophan" | ||
|
||
"UAA" -> | ||
Ok "STOP" | ||
|
||
"UAG" -> | ||
Ok "STOP" | ||
|
||
"UGA" -> | ||
Ok "STOP" | ||
|
||
_ -> | ||
Err "Invalid codon" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"src" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"elm/core": "1.0.5", | ||
"elm/json": "1.1.3", | ||
"elm/parser": "1.1.0", | ||
"elm/random": "1.0.0", | ||
"elm/regex": "1.0.0", | ||
"elm/time": "1.0.0" | ||
}, | ||
"indirect": {} | ||
}, | ||
"test-dependencies": { | ||
"direct": { | ||
"elm-explorations/test": "2.1.0", | ||
"rtfeldman/elm-iso8601-date-strings": "1.1.4" | ||
}, | ||
"indirect": { | ||
"elm/bytes": "1.0.8", | ||
"elm/html": "1.0.0", | ||
"elm/virtual-dom": "1.0.3" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
exercises/practice/protein-translation/src/ProteinTranslation.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module ProteinTranslation exposing (proteins) | ||
|
||
|
||
proteins : String -> Result String List todo | ||
proteins strand = | ||
Debug.todo "Please implement proteins" |
Oops, something went wrong.