Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@
"arrays",
"modulo"
]
},
{
"uuid": "8ebcfe11-0a42-e980-d120-fb3fd581e426e9e237e",
"slug": "rna-transcription",
"core": false,
"unlocked_by": null,
"difficulty": 1,
"topics": [
"maybe",
"strings"
]
}
],
"foregone": [
Expand Down
25 changes: 25 additions & 0 deletions exercises/rna-transcription/README.md
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.
26 changes: 26 additions & 0 deletions exercises/rna-transcription/bower.json
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",
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor

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

"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 exercises/rna-transcription/examples/src/RNATranscription.purs
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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
3 changes: 3 additions & 0 deletions exercises/rna-transcription/src/RNATranscription.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module RNATranscription
( toRNA
) where
48 changes: 48 additions & 0 deletions exercises/rna-transcription/test/Main.purs
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")