-
-
Notifications
You must be signed in to change notification settings - Fork 14
Add practice exercise: protein-translation #137
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
exercises/practice/protein-translation/.docs/instructions.md
This file contains hidden or 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,38 @@ | ||
| # Instructions | ||
|
|
||
| Your job is to translate RNA sequences into proteins. | ||
|
|
||
| RNA strands are made up of three-nucleotide sequences called **codons**. | ||
| Each codon translates to an **amino acid**. | ||
| When joined together, those amino acids make a protein. | ||
|
|
||
| In the real world, there are 64 codons, which in turn correspond to 20 amino acids. | ||
| However, for this exercise, you’ll only use a few of the possible 64. | ||
| They are listed below: | ||
|
|
||
| | Codon | Amino Acid | | ||
| | ------------------ | ------------- | | ||
| | 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 | | ||
|
|
||
| For example, the RNA string “AUGUUUUCU” has three codons: “AUG”, “UUU” and “UCU”. | ||
| These map to Methionine, Phenylalanine, and Serine. | ||
|
|
||
| ## “STOP” Codons | ||
|
|
||
| You’ll note from the table above that there are three **“STOP” codons**. | ||
| If you encounter any of these codons, ignore the rest of the sequence — the protein is complete. | ||
|
|
||
| For example, “AUGUUUUCUUAAAUG” contains a STOP codon (“UAA”). | ||
| Once we reach that point, we stop processing. | ||
| We therefore only consider the part before it (i.e. “AUGUUUUCU”), not any further codons after it (i.e. “AUG”). | ||
|
|
||
| Learn more about [protein translation on Wikipedia][protein-translation]. | ||
|
|
||
| [protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology) |
This file contains hidden or 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": [ | ||
| "jimmytty" | ||
| ], | ||
| "files": { | ||
| "solution": [ | ||
| "protein-translation.sql" | ||
| ], | ||
| "test": [ | ||
| "protein-translation_test.sql" | ||
| ], | ||
| "example": [ | ||
| ".meta/example.sql" | ||
| ] | ||
| }, | ||
| "blurb": "Translate RNA sequences into proteins.", | ||
| "source": "Tyler Long" | ||
| } |
This file contains hidden or 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,70 @@ | ||
| DROP TABLE IF EXISTS dict; | ||
| CREATE TEMPORARY TABLE dict ( | ||
| codon TEXT PRIMARY KEY, | ||
| amino_acid TEXT NOT NULL | ||
| ); | ||
| INSERT INTO dict(codon, amino_acid) | ||
| VALUES ('AUG', 'Methionine' ), | ||
| ('UUU', 'Phenylalanine'), | ||
| ('UUC', 'Phenylalanine'), | ||
| ('UUA', 'Leucine' ), | ||
| ('UUG', 'Leucine' ), | ||
| ('UCU', 'Serine' ), | ||
| ('UCC', 'Serine' ), | ||
| ('UCA', 'Serine' ), | ||
| ('UCG', 'Serine' ), | ||
| ('UAU', 'Tyrosine' ), | ||
| ('UAC', 'Tyrosine' ), | ||
| ('UGU', 'Cysteine' ), | ||
| ('UGC', 'Cysteine' ), | ||
| ('UGG', 'Tryptophan' ), | ||
| ('UAA', 'STOP' ), | ||
| ('UAG', 'STOP' ), | ||
| ('UGA', 'STOP' ); | ||
|
|
||
| DROP TABLE IF EXISTS results; | ||
| CREATE TEMPORARY TABLE results AS | ||
| SELECT strand, | ||
| (WITH RECURSIVE translator (string, codon, amino_acid) AS ( | ||
| VALUES (strand, '', '') | ||
| UNION ALL | ||
| SELECT SUBSTR(string, 4), | ||
| SUBSTR(string, 1, 3), | ||
| (SELECT amino_acid | ||
| FROM dict | ||
| WHERE dict.codon = SUBSTR(string, 1, 3)) | ||
| FROM translator | ||
| WHERE string <> '' | ||
| AND amino_acid <> 'STOP' | ||
| ) | ||
| SELECT | ||
| CASE | ||
| WHEN (SELECT 1 | ||
| FROM translator | ||
| WHERE amino_acid ISNULL) | ||
| THEN 'Invalid codon' | ||
| WHEN (SELECT COUNT(*) FILTER(WHERE amino_acid <> '') = | ||
| COUNT(*) FILTER(WHERE amino_acid = 'STOP') | ||
| FROM translator) | ||
| THEN '' | ||
| ELSE (SELECT GROUP_CONCAT(amino_acid, ', ') | ||
| FROM translator | ||
| WHERE amino_acid NOT IN ('', 'STOP')) | ||
| END | ||
| ) result_or_error | ||
| FROM "protein-translation" | ||
| ; | ||
|
|
||
| UPDATE "protein-translation" AS pt | ||
| SET error = result_or_error | ||
IsaacG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FROM results re | ||
| WHERE pt.strand = re.strand | ||
| AND result_or_error = 'Invalid codon' | ||
| ; | ||
|
|
||
| UPDATE "protein-translation" AS pt | ||
| SET result = result_or_error | ||
| FROM results re | ||
| WHERE pt.strand = re.strand | ||
| AND result_or_error <> 'Invalid codon' | ||
| ; | ||
105 changes: 105 additions & 0 deletions
105
exercises/practice/protein-translation/.meta/tests.toml
This file contains hidden or 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,105 @@ | ||
| # 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" | ||
|
|
||
| [1b4c56d8-d69f-44eb-be0e-7b17546143d9] | ||
| description = "Phenylalanine RNA sequence 1" | ||
|
|
||
| [81b53646-bd57-4732-b2cb-6b1880e36d11] | ||
| description = "Phenylalanine RNA sequence 2" | ||
|
|
||
| [42f69d4f-19d2-4d2c-a8b0-f0ae9ee1b6b4] | ||
| description = "Leucine RNA sequence 1" | ||
|
|
||
| [ac5edadd-08ed-40a3-b2b9-d82bb50424c4] | ||
| description = "Leucine RNA sequence 2" | ||
|
|
||
| [8bc36e22-f984-44c3-9f6b-ee5d4e73f120] | ||
| description = "Serine RNA sequence 1" | ||
|
|
||
| [5c3fa5da-4268-44e5-9f4b-f016ccf90131] | ||
| description = "Serine RNA sequence 2" | ||
|
|
||
| [00579891-b594-42b4-96dc-7ff8bf519606] | ||
| description = "Serine RNA sequence 3" | ||
|
|
||
| [08c61c3b-fa34-4950-8c4a-133945570ef6] | ||
| description = "Serine RNA sequence 4" | ||
|
|
||
| [54e1e7d8-63c0-456d-91d2-062c72f8eef5] | ||
| description = "Tyrosine RNA sequence 1" | ||
|
|
||
| [47bcfba2-9d72-46ad-bbce-22f7666b7eb1] | ||
| description = "Tyrosine RNA sequence 2" | ||
|
|
||
| [3a691829-fe72-43a7-8c8e-1bd083163f72] | ||
| description = "Cysteine RNA sequence 1" | ||
|
|
||
| [1b6f8a26-ca2f-43b8-8262-3ee446021767] | ||
| description = "Cysteine RNA sequence 2" | ||
|
|
||
| [1e91c1eb-02c0-48a0-9e35-168ad0cb5f39] | ||
| description = "Tryptophan RNA sequence" | ||
|
|
||
| [e547af0b-aeab-49c7-9f13-801773a73557] | ||
| description = "STOP codon RNA sequence 1" | ||
|
|
||
| [67640947-ff02-4f23-a2ef-816f8a2ba72e] | ||
| 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" | ||
|
|
||
| [e30e8505-97ec-4e5f-a73e-5726a1faa1f4] | ||
| description = "Translation stops if STOP codon at beginning of sequence" | ||
|
|
||
| [5358a20b-6f4c-4893-bce4-f929001710f3] | ||
| description = "Translation stops if STOP codon at end of two-codon sequence" | ||
|
|
||
| [ba16703a-1a55-482f-bb07-b21eef5093a3] | ||
| description = "Translation stops if STOP codon at end of three-codon sequence" | ||
|
|
||
| [4089bb5a-d5b4-4e71-b79e-b8d1f14a2911] | ||
| 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" | ||
|
|
||
| [9d73899f-e68e-4291-b1e2-7bf87c00f024] | ||
| description = "Incomplete RNA sequence can't translate" | ||
|
|
||
| [43945cf7-9968-402d-ab9f-b8a28750b050] | ||
| description = "Incomplete RNA sequence can translate if valid until a STOP codon" |
This file contains hidden or 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,11 @@ | ||
| DROP TABLE IF EXISTS "protein-translation"; | ||
| CREATE TABLE "protein-translation" ( | ||
| strand TEXT NOT NULL, | ||
IsaacG marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| result TEXT , | ||
| error TEXT | ||
| ); | ||
|
|
||
| .mode csv | ||
| .import ./data.csv "protein-translation" | ||
|
|
||
| UPDATE "protein-translation" SET result = NULL, error = NULL; | ||
49 changes: 49 additions & 0 deletions
49
exercises/practice/protein-translation/create_test_table.sql
This file contains hidden or 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,49 @@ | ||
| DROP TABLE IF EXISTS tests; | ||
| CREATE TABLE IF NOT EXISTS tests ( | ||
| -- uuid and description are taken from the test.toml file | ||
| uuid TEXT PRIMARY KEY , | ||
| description 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 | ||
| strand TEXT NOT NULL , | ||
| expected_result TEXT , | ||
| expected_error TEXT | ||
| ); | ||
|
|
||
| INSERT INTO tests (uuid, description, strand, expected_result, expected_error) | ||
| VALUES | ||
| ('2c44f7bf-ba20-43f7-a3bf-f2219c0c3f98', 'Empty RNA sequence results in no proteins', '', '', NULL), | ||
| ('96d3d44f-34a2-4db4-84cd-fff523e069be', 'Methionine RNA sequence', 'AUG', 'Methionine', NULL), | ||
| ('1b4c56d8-d69f-44eb-be0e-7b17546143d9', 'Phenylalanine RNA sequence 1', 'UUU', 'Phenylalanine', NULL), | ||
| ('81b53646-bd57-4732-b2cb-6b1880e36d11', 'Phenylalanine RNA sequence 2', 'UUC', 'Phenylalanine', NULL), | ||
| ('42f69d4f-19d2-4d2c-a8b0-f0ae9ee1b6b4', 'Leucine RNA sequence 1', 'UUA', 'Leucine', NULL), | ||
| ('ac5edadd-08ed-40a3-b2b9-d82bb50424c4', 'Leucine RNA sequence 2', 'UUG', 'Leucine', NULL), | ||
| ('8bc36e22-f984-44c3-9f6b-ee5d4e73f120', 'Serine RNA sequence 1', 'UCU', 'Serine', NULL), | ||
| ('5c3fa5da-4268-44e5-9f4b-f016ccf90131', 'Serine RNA sequence 2', 'UCC', 'Serine', NULL), | ||
| ('00579891-b594-42b4-96dc-7ff8bf519606', 'Serine RNA sequence 3', 'UCA', 'Serine', NULL), | ||
| ('08c61c3b-fa34-4950-8c4a-133945570ef6', 'Serine RNA sequence 4', 'UCG', 'Serine', NULL), | ||
| ('54e1e7d8-63c0-456d-91d2-062c72f8eef5', 'Tyrosine RNA sequence 1', 'UAU', 'Tyrosine', NULL), | ||
| ('47bcfba2-9d72-46ad-bbce-22f7666b7eb1', 'Tyrosine RNA sequence 2', 'UAC', 'Tyrosine', NULL), | ||
| ('3a691829-fe72-43a7-8c8e-1bd083163f72', 'Cysteine RNA sequence 1', 'UGU', 'Cysteine', NULL), | ||
| ('1b6f8a26-ca2f-43b8-8262-3ee446021767', 'Cysteine RNA sequence 2', 'UGC', 'Cysteine', NULL), | ||
| ('1e91c1eb-02c0-48a0-9e35-168ad0cb5f39', 'Tryptophan RNA sequence', 'UGG', 'Tryptophan', NULL), | ||
| ('e547af0b-aeab-49c7-9f13-801773a73557', 'STOP codon RNA sequence 1', 'UAA', '', NULL), | ||
| ('67640947-ff02-4f23-a2ef-816f8a2ba72e', 'STOP codon RNA sequence 2', 'UAG', '', NULL), | ||
| ('9c2ad527-ebc9-4ace-808b-2b6447cb54cb', 'STOP codon RNA sequence 3', 'UGA', '', NULL), | ||
| ('f4d9d8ee-00a8-47bf-a1e3-1641d4428e54', 'Sequence of two protein codons translates into proteins', 'UUUUUU', 'Phenylalanine, Phenylalanine', NULL), | ||
| ('dd22eef3-b4f1-4ad6-bb0b-27093c090a9d', 'Sequence of two different protein codons translates into proteins', 'UUAUUG', 'Leucine, Leucine', NULL), | ||
| ('d0f295df-fb70-425c-946c-ec2ec185388e', 'Translate RNA strand into correct protein list', 'AUGUUUUGG', 'Methionine, Phenylalanine, Tryptophan', NULL), | ||
| ('e30e8505-97ec-4e5f-a73e-5726a1faa1f4', 'Translation stops if STOP codon at beginning of sequence', 'UAGUGG', '', NULL), | ||
| ('5358a20b-6f4c-4893-bce4-f929001710f3', 'Translation stops if STOP codon at end of two-codon sequence', 'UGGUAG', 'Tryptophan', NULL), | ||
| ('ba16703a-1a55-482f-bb07-b21eef5093a3', 'Translation stops if STOP codon at end of three-codon sequence', 'AUGUUUUAA', 'Methionine, Phenylalanine', NULL), | ||
| ('4089bb5a-d5b4-4e71-b79e-b8d1f14a2911', 'Translation stops if STOP codon in middle of three-codon sequence', 'UGGUAGUGG', 'Tryptophan', NULL), | ||
| ('2c2a2a60-401f-4a80-b977-e0715b23b93d', 'Translation stops if STOP codon in middle of six-codon sequence', 'UGGUGUUAUUAAUGGUUU', 'Tryptophan, Cysteine, Tyrosine', NULL), | ||
| ('f6f92714-769f-4187-9524-e353e8a41a80', 'Sequence of two non-STOP codons does not translate to a STOP codon', 'AUGAUG', 'Methionine, Methionine', NULL), | ||
| ('9eac93f3-627a-4c90-8653-6d0a0595bc6f', 'Unknown amino acids, not part of a codon, can''t translate', 'XYZ', NULL, 'Invalid codon'), | ||
| ('9d73899f-e68e-4291-b1e2-7bf87c00f024', 'Incomplete RNA sequence can''t translate', 'AUGU', NULL, 'Invalid codon'), | ||
| ('43945cf7-9968-402d-ab9f-b8a28750b050', 'Incomplete RNA sequence can translate if valid until a STOP codon', 'UUCUUCUAAUGGU', 'Phenylalanine, Phenylalanine', NULL); |
This file contains hidden or 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,30 @@ | ||
| "",, | ||
| "AUG",, | ||
| "UUU",, | ||
| "UUC",, | ||
| "UUA",, | ||
| "UUG",, | ||
| "UCU",, | ||
| "UCC",, | ||
| "UCA",, | ||
| "UCG",, | ||
| "UAU",, | ||
| "UAC",, | ||
| "UGU",, | ||
| "UGC",, | ||
| "UGG",, | ||
| "UAA",, | ||
| "UAG",, | ||
| "UGA",, | ||
| "UUUUUU",, | ||
| "UUAUUG",, | ||
| "AUGUUUUGG",, | ||
| "UAGUGG",, | ||
| "UGGUAG",, | ||
| "AUGUUUUAA",, | ||
| "UGGUAGUGG",, | ||
| "UGGUGUUAUUAAUGGUUU",, | ||
| "AUGAUG",, | ||
| "XYZ",, | ||
| "AUGU",, | ||
| "UUCUUCUAAUGGU",, |
8 changes: 8 additions & 0 deletions
8
exercises/practice/protein-translation/protein-translation.sql
This file contains hidden or 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,8 @@ | ||
| -- Schema: | ||
| -- CREATE TABLE "protein-translation" ( | ||
| -- strand TEXT NOT NULL, | ||
| -- result TEXT , | ||
| -- error TEXT | ||
| -- ); | ||
| -- | ||
| -- Task: update the protein-translation and set the result or the error columns based on strand. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.