-
-
Notifications
You must be signed in to change notification settings - Fork 35
Add RNA Transcription exercise #74
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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,25 @@ | ||
| # Rna Transcription | ||
|
|
||
| Given a DNA strand, return its RNA complement (per RNA transcription). | ||
|
|
||
| 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` | ||
| ## Source | ||
|
|
||
| Rosalind [http://rosalind.info/problems/rna](http://rosalind.info/problems/rna) | ||
|
|
||
| ## Submitting Incomplete Solutions | ||
| It's possible to submit an incomplete solution so you can see how others have completed the exercise. |
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,26 @@ | ||
| { | ||
| "name": "rna-transcription", | ||
| "ignore": [ | ||
| "**/.*", | ||
| "node_modules", | ||
| "bower_components", | ||
| "output" | ||
| ], | ||
| "dependencies": { | ||
| "purescript-console": "^3.0.0", | ||
| "purescript-datetime": "^3.4.0", | ||
| "purescript-either": "^3.1.0", | ||
| "purescript-enums": "^3.2.1", | ||
| "purescript-integers": "^3.1.0", | ||
| "purescript-lists": "^4.10.0", | ||
| "purescript-maps": "^3.5.2", | ||
| "purescript-prelude": "^3.1.0", | ||
| "purescript-sets": "^3.0.0", | ||
| "purescript-strings": "^3.3.1", | ||
| "purescript-unicode": "^3.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "purescript-psci-support": "^3.0.0", | ||
| "purescript-test-unit": "^13.0.0" | ||
| } | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
exercises/rna-transcription/examples/src/RNATranscription.purs
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 @@ | ||
| module RNATranscription | ||
| ( toRNA | ||
| ) where | ||
|
|
||
| import Prelude | ||
| import Data.Maybe (Maybe(..)) | ||
| import Data.String (fromCharArray, toCharArray) | ||
| import Data.Traversable (traverse) | ||
|
|
||
| toRNA :: String -> Maybe String | ||
| toRNA dna = fromCharArray <$> traverse complement (toCharArray dna) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
|
||
| complement :: Char -> Maybe Char | ||
| complement 'C' = Just 'G' | ||
| complement 'G' = Just 'C' | ||
| complement 'A' = Just 'U' | ||
| complement 'T' = Just 'A' | ||
| complement _ = Nothing | ||
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,3 @@ | ||
| module RNATranscription | ||
| ( toRNA | ||
| ) where |
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,48 @@ | ||
| module Test.Main where | ||
|
|
||
| import Prelude | ||
| import Control.Monad.Eff (Eff) | ||
| import Control.Monad.Eff.AVar (AVAR) | ||
| import Control.Monad.Eff.Console (CONSOLE) | ||
| import Data.Maybe (Maybe(..)) | ||
| import Test.Unit (TestSuite, suite, test) | ||
| import Test.Unit.Assert as Assert | ||
| import Test.Unit.Console (TESTOUTPUT) | ||
| import Test.Unit.Main (runTest) | ||
| import RNATranscription (toRNA) | ||
|
|
||
| main :: forall eff | ||
| . Eff ( avar :: AVAR | ||
| , console :: CONSOLE | ||
| , testOutput :: TESTOUTPUT | ||
| | eff | ||
| ) | ||
| Unit | ||
| main = runTest suites | ||
|
|
||
| suites :: forall e. TestSuite e | ||
| suites = | ||
| suite "RNATranscription.toRNA" do | ||
| test "RNA complement of cytosine is guanine" $ | ||
| Assert.equal (Just "G") (toRNA "C") | ||
|
|
||
| test "RNA complement of guanine is cytosine" $ | ||
| Assert.equal (Just "C") (toRNA "G") | ||
|
|
||
| test "RNA complement of thymine is adenine" $ | ||
| Assert.equal (Just "A") (toRNA "T") | ||
|
|
||
| test "RNA complement of adenine is uracil" $ | ||
| Assert.equal (Just "U") (toRNA "A") | ||
|
|
||
| test "RNA complement" $ | ||
| Assert.equal (Just "UGCACCAGAAUU") (toRNA "ACGTGGTCTTAA") | ||
|
|
||
| test "correctly handles invalid input (RNA instead of DNA)" $ | ||
| Assert.equal Nothing (toRNA "U") | ||
|
|
||
| test "correctly handles completely invalid DNA input" $ | ||
| Assert.equal Nothing (toRNA "XXX") | ||
|
|
||
| test "correctly handles partially invalid DNA input" $ | ||
| Assert.equal Nothing (toRNA "ACGTXXXCTTAA") |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need all of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, not sure what the deal is with the individual bower json files, the README isn't so clear. All of the exercises seem to have the same set of dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe all the exercises share the same deps now so that we can cache easier on CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh....
Ok, ignore me then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@houli Can you open an issue with details about what was unclear in the README, so I submit a PR to clear things up for future contributors?
@paf31 Yes, recently changed, details in: #71, #72 and #73