-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
9 changed files
with
172 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
20 changes: 20 additions & 0 deletions
20
exercises/practice/rna-transcription/.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,20 @@ | ||
# Instructions | ||
|
||
Your task is determine the RNA complement of a given DNA sequence. | ||
|
||
Both DNA and RNA strands are a sequence of nucleotides. | ||
|
||
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**). | ||
|
||
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**). | ||
|
||
Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: | ||
|
||
- `G` -> `C` | ||
- `C` -> `G` | ||
- `T` -> `A` | ||
- `A` -> `U` | ||
|
||
~~~~exercism/note | ||
If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite. | ||
~~~~ |
16 changes: 16 additions & 0 deletions
16
exercises/practice/rna-transcription/.docs/introduction.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,16 @@ | ||
# Introduction | ||
|
||
You work for a bioengineering company that specializes in developing therapeutic solutions. | ||
|
||
Your team has just been given a new project to develop a targeted therapy for a rare type of cancer. | ||
|
||
~~~~exercism/note | ||
It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein. | ||
That can cause all sorts of havoc. | ||
But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced. | ||
This technique is called [RNA Interference][rnai]. | ||
[rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/ | ||
~~~~ |
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,20 @@ | ||
module [toRna] | ||
|
||
complement = \nucleotide -> | ||
when nucleotide is | ||
'G' -> 'C' | ||
'C' -> 'G' | ||
'T' -> 'A' | ||
'A' -> 'U' | ||
c -> c # invalid nucleotides are ignored | ||
|
||
toRna = \dna -> | ||
maybeRna = | ||
dna | ||
|> Str.toUtf8 | ||
|> List.map complement | ||
|> Str.fromUtf8 | ||
|
||
when maybeRna is | ||
Ok rna -> rna | ||
Err _ -> crash "Unreachable code: toUt8 -> fromUtf8 will always be Ok" |
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,19 @@ | ||
{ | ||
"authors": [ | ||
"ageron" | ||
], | ||
"files": { | ||
"solution": [ | ||
"RnaTranscription.roc" | ||
], | ||
"test": [ | ||
"rna-transcription-test.roc" | ||
], | ||
"example": [ | ||
".meta/Example.roc" | ||
] | ||
}, | ||
"blurb": "Given a DNA strand, return its RNA Complement Transcription.", | ||
"source": "Hyperphysics", | ||
"source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html" | ||
} |
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,13 @@ | ||
{%- import "generator_macros.j2" as macros with context -%} | ||
{{ macros.canonical_ref() }} | ||
{{ macros.header() }} | ||
|
||
import {{ exercise | to_pascal }} exposing [toRna] | ||
|
||
{% for case in cases -%} | ||
# {{ case["description"] }} | ||
expect | ||
result = {{ case["property"] | to_camel }} {{ case["input"]["dna"] | to_roc }} | ||
result == {{ case["expected"] | to_roc }} | ||
|
||
{% endfor %} |
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,28 @@ | ||
# 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. | ||
|
||
[b4631f82-c98c-4a2f-90b3-c5c2b6c6f661] | ||
description = "Empty RNA sequence" | ||
|
||
[a9558a3c-318c-4240-9256-5d5ed47005a6] | ||
description = "RNA complement of cytosine is guanine" | ||
|
||
[6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7] | ||
description = "RNA complement of guanine is cytosine" | ||
|
||
[870bd3ec-8487-471d-8d9a-a25046488d3e] | ||
description = "RNA complement of thymine is adenine" | ||
|
||
[aade8964-02e1-4073-872f-42d3ffd74c5f] | ||
description = "RNA complement of adenine is uracil" | ||
|
||
[79ed2757-f018-4f47-a1d7-34a559392dbf] | ||
description = "RNA complement" |
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,4 @@ | ||
module [toRna] | ||
|
||
toRna = \dna -> | ||
crash "Please implement the 'toRna' function" |
44 changes: 44 additions & 0 deletions
44
exercises/practice/rna-transcription/rna-transcription-test.roc
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,44 @@ | ||
# These tests are auto-generated with test data from: | ||
# https://github.com/exercism/problem-specifications/tree/main/exercises/rna-transcription/canonical-data.json | ||
# File last updated on 2024-08-27 | ||
app [main] { | ||
pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.14.0/dC5ceT962N_4jmoyoffVdphJ_4GlW3YMhAPyGPr-nU0.tar.br", | ||
} | ||
|
||
import pf.Task exposing [Task] | ||
|
||
main = | ||
Task.ok {} | ||
|
||
import RnaTranscription exposing [toRna] | ||
|
||
# Empty RNA sequence | ||
expect | ||
result = toRna "" | ||
result == "" | ||
|
||
# RNA complement of cytosine is guanine | ||
expect | ||
result = toRna "C" | ||
result == "G" | ||
|
||
# RNA complement of guanine is cytosine | ||
expect | ||
result = toRna "G" | ||
result == "C" | ||
|
||
# RNA complement of thymine is adenine | ||
expect | ||
result = toRna "T" | ||
result == "A" | ||
|
||
# RNA complement of adenine is uracil | ||
expect | ||
result = toRna "A" | ||
result == "U" | ||
|
||
# RNA complement | ||
expect | ||
result = toRna "ACGTGGTCTTAA" | ||
result == "UGCACCAGAAUU" | ||
|