diff --git a/config.json b/config.json index bfe4b2f..1a73e2a 100644 --- a/config.json +++ b/config.json @@ -217,6 +217,14 @@ "practices": [], "prerequisites": [], "difficulty": 8 + }, + { + "slug": "rna-transcription", + "name": "RNA Transcription", + "uuid": "71556996-0d47-4c34-bd8c-373d55ee03fd", + "practices": [], + "prerequisites": [], + "difficulty": 2 } ] }, diff --git a/exercises/practice/rna-transcription/.docs/instructions.md b/exercises/practice/rna-transcription/.docs/instructions.md new file mode 100644 index 0000000..36da381 --- /dev/null +++ b/exercises/practice/rna-transcription/.docs/instructions.md @@ -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. +~~~~ diff --git a/exercises/practice/rna-transcription/.docs/introduction.md b/exercises/practice/rna-transcription/.docs/introduction.md new file mode 100644 index 0000000..6b3f44b --- /dev/null +++ b/exercises/practice/rna-transcription/.docs/introduction.md @@ -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/ +~~~~ diff --git a/exercises/practice/rna-transcription/.meta/config.json b/exercises/practice/rna-transcription/.meta/config.json new file mode 100644 index 0000000..d6566ff --- /dev/null +++ b/exercises/practice/rna-transcription/.meta/config.json @@ -0,0 +1,22 @@ +{ + "authors": [ + "Steffan153" + ], + "files": { + "solution": [ + "rna-transcription.sql" + ], + "test": [ + "rna-transcription_test.sql" + ], + "example": [ + ".meta/example.sql" + ], + "editor": [ + "data.csv" + ] + }, + "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" +} diff --git a/exercises/practice/rna-transcription/.meta/example.sql b/exercises/practice/rna-transcription/.meta/example.sql new file mode 100644 index 0000000..e7a362d --- /dev/null +++ b/exercises/practice/rna-transcription/.meta/example.sql @@ -0,0 +1,14 @@ +UPDATE "rna-transcription" +SET result = REPLACE( + REPLACE( + REPLACE( + REPLACE( + REPLACE(dna, 'A', 'U'), + 'T', 'A' + ), + 'C', 'Z' + ), + 'G', 'C' + ), + 'Z', 'G' +); diff --git a/exercises/practice/rna-transcription/.meta/tests.toml b/exercises/practice/rna-transcription/.meta/tests.toml new file mode 100644 index 0000000..6800514 --- /dev/null +++ b/exercises/practice/rna-transcription/.meta/tests.toml @@ -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" diff --git a/exercises/practice/rna-transcription/canonical-data.json b/exercises/practice/rna-transcription/canonical-data.json new file mode 100644 index 0000000..d05146e --- /dev/null +++ b/exercises/practice/rna-transcription/canonical-data.json @@ -0,0 +1,59 @@ +{ + "exercise": "rna-transcription", + "cases": [ + { + "uuid": "b4631f82-c98c-4a2f-90b3-c5c2b6c6f661", + "description": "Empty RNA sequence", + "property": "toRna", + "input": { + "dna": "" + }, + "expected": "" + }, + { + "uuid": "a9558a3c-318c-4240-9256-5d5ed47005a6", + "description": "RNA complement of cytosine is guanine", + "property": "toRna", + "input": { + "dna": "C" + }, + "expected": "G" + }, + { + "uuid": "6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7", + "description": "RNA complement of guanine is cytosine", + "property": "toRna", + "input": { + "dna": "G" + }, + "expected": "C" + }, + { + "uuid": "870bd3ec-8487-471d-8d9a-a25046488d3e", + "description": "RNA complement of thymine is adenine", + "property": "toRna", + "input": { + "dna": "T" + }, + "expected": "A" + }, + { + "uuid": "aade8964-02e1-4073-872f-42d3ffd74c5f", + "description": "RNA complement of adenine is uracil", + "property": "toRna", + "input": { + "dna": "A" + }, + "expected": "U" + }, + { + "uuid": "79ed2757-f018-4f47-a1d7-34a559392dbf", + "description": "RNA complement", + "property": "toRna", + "input": { + "dna": "ACGTGGTCTTAA" + }, + "expected": "UGCACCAGAAUU" + } + ] +} diff --git a/exercises/practice/rna-transcription/create_fixture.sql b/exercises/practice/rna-transcription/create_fixture.sql new file mode 100644 index 0000000..8b3fc88 --- /dev/null +++ b/exercises/practice/rna-transcription/create_fixture.sql @@ -0,0 +1,8 @@ +DROP TABLE IF EXISTS "rna-transcription"; +CREATE TABLE "rna-transcription" ( + "dna" TEXT, + "result" TEXT +); + +.mode csv +.import ./data.csv rna-transcription diff --git a/exercises/practice/rna-transcription/data.csv b/exercises/practice/rna-transcription/data.csv new file mode 100644 index 0000000..661f1db --- /dev/null +++ b/exercises/practice/rna-transcription/data.csv @@ -0,0 +1,6 @@ +"","" +"C","" +"G","" +"T","" +"A","" +"ACGTGGTCTTAA","" diff --git a/exercises/practice/rna-transcription/rna-transcription.sql b/exercises/practice/rna-transcription/rna-transcription.sql new file mode 100644 index 0000000..6bdb443 --- /dev/null +++ b/exercises/practice/rna-transcription/rna-transcription.sql @@ -0,0 +1,2 @@ +-- Schema: CREATE TABLE "rna-transcription" ("dna" TEXT, "result" TEXT); +-- Task: update the rna-transcription table and set the result based on the dna field. diff --git a/exercises/practice/rna-transcription/rna-transcription_test.sql b/exercises/practice/rna-transcription/rna-transcription_test.sql new file mode 100644 index 0000000..cd983ba --- /dev/null +++ b/exercises/practice/rna-transcription/rna-transcription_test.sql @@ -0,0 +1,21 @@ +-- Setup test table and read in student solution: +.read ./test_setup.sql + +-- Test cases: +INSERT INTO tests (name, uuid, dna, expected) + VALUES + ('Empty RNA sequence', 'b4631f82-c98c-4a2f-90b3-c5c2b6c6f661', '', ''), + ('RNA complement of cytosine is guanine', 'a9558a3c-318c-4240-9256-5d5ed47005a6', 'C', 'G'), + ('RNA complement of guanine is cytosine', '6eedbb5c-12cb-4c8b-9f51-f8320b4dc2e7', 'G', 'C'), + ('RNA complement of thymine is adenine', '870bd3ec-8487-471d-8d9a-a25046488d3e', 'T', 'A'), + ('RNA complement of adenine is uracil', 'aade8964-02e1-4073-872f-42d3ffd74c5f', 'A', 'U'), + ('RNA complement', '79ed2757-f018-4f47-a1d7-34a559392dbf', 'ACGTGGTCTTAA', 'UGCACCAGAAUU'); + +-- Comparison of user input and the tests updates the status for each test: +UPDATE tests +SET status = 'pass' +FROM (SELECT dna, result FROM "rna-transcription") AS actual +WHERE (actual.dna, actual.result) = (tests.dna, tests.expected); + +-- Write results and debug info: +.read ./test_reporter.sql diff --git a/exercises/practice/rna-transcription/test_reporter.sql b/exercises/practice/rna-transcription/test_reporter.sql new file mode 100644 index 0000000..a48690d --- /dev/null +++ b/exercises/practice/rna-transcription/test_reporter.sql @@ -0,0 +1,16 @@ +-- Update message for failed tests to give helpful information: +UPDATE tests +SET message = 'Result for "' || tests.dna || '" is "' || actual.result || '", but should be "' || tests.expected || '"' +FROM (SELECT dna, result FROM 'rna-transcription') AS actual +WHERE actual.dna = tests.dna AND tests.status = 'fail'; + +-- Save results to ./output.json (needed by the online test-runner) +.mode json +.once './output.json' +SELECT name, status, message, output, test_code, task_id +FROM tests; + +-- Display test results in readable form for the student: +.mode table +SELECT name, status, message +FROM tests; diff --git a/exercises/practice/rna-transcription/test_setup.sql b/exercises/practice/rna-transcription/test_setup.sql new file mode 100644 index 0000000..445e297 --- /dev/null +++ b/exercises/practice/rna-transcription/test_setup.sql @@ -0,0 +1,25 @@ +-- Create database: +.read ./create_fixture.sql + +-- Read user student solution and save any output as markdown in user_output.md: +.mode markdown +.output user_output.md +.read ./rna-transcription.sql +.output + +-- Create a clean testing environment: +DROP TABLE IF EXISTS tests; +CREATE TABLE IF NOT EXISTS tests ( + -- uuid and name (description) are taken from the test.toml file + uuid TEXT PRIMARY KEY, + name TEXT NOT NULL, + -- The following section is needed by the online test-runner + status TEXT DEFAULT 'fail', + message TEXT, + output TEXT, + test_code TEXT, + task_id INTEGER DEFAULT NULL, + -- Here are columns for the actual tests + dna TEXT NOT NULL, + expected TEXT NOT NULL +);