rna-transcription
This commit is contained in:
parent
c7b7989ccd
commit
8a0b02049f
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"authors": [
|
||||
"rubysolo"
|
||||
],
|
||||
"contributors": [
|
||||
"angelikatyborska",
|
||||
"Cohen-Carlisle",
|
||||
"dalexj",
|
||||
"devonestes",
|
||||
"drueck",
|
||||
"jinyeow",
|
||||
"lpil",
|
||||
"neenjaw",
|
||||
"parkerl",
|
||||
"pminten",
|
||||
"sotojuan",
|
||||
"Teapane",
|
||||
"tjcelaya",
|
||||
"veelenga",
|
||||
"waiting-for-dev"
|
||||
],
|
||||
"files": {
|
||||
"solution": [
|
||||
"lib/rna_transcription.ex"
|
||||
],
|
||||
"test": [
|
||||
"test/rna_transcription_test.exs"
|
||||
],
|
||||
"example": [
|
||||
".meta/example.ex"
|
||||
]
|
||||
},
|
||||
"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"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
{"track":"elixir","exercise":"rna-transcription","id":"63ab8e36c9144f84a7fdc34eb6d56856","url":"https://exercism.org/tracks/elixir/exercises/rna-transcription","handle":"negrienko","is_requester":true,"auto_approve":false}
|
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -0,0 +1,24 @@
|
|||
# The directory Mix will write compiled artifacts to.
|
||||
/_build/
|
||||
|
||||
# If you run "mix test --cover", coverage assets end up here.
|
||||
/cover/
|
||||
|
||||
# The directory Mix downloads your dependencies sources to.
|
||||
/deps/
|
||||
|
||||
# Where third-party dependencies like ExDoc output generated docs.
|
||||
/doc/
|
||||
|
||||
# Ignore .fetch files in case you like to edit your project deps locally.
|
||||
/.fetch
|
||||
|
||||
# If the VM crashes, it generates a dump, let's ignore it too.
|
||||
erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore package tarball (built via "mix hex.build").
|
||||
rna_transcription-*.tar
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
# Help
|
||||
|
||||
## Running the tests
|
||||
|
||||
From the terminal, change to the base directory of the exercise then execute the tests with:
|
||||
|
||||
```bash
|
||||
$ mix test
|
||||
```
|
||||
|
||||
This will execute the test file found in the `test` subfolder -- a file ending in `_test.exs`
|
||||
|
||||
Documentation:
|
||||
|
||||
* [`mix test` - Elixir's test execution tool](https://hexdocs.pm/mix/Mix.Tasks.Test.html)
|
||||
* [`ExUnit` - Elixir's unit test library](https://hexdocs.pm/ex_unit/ExUnit.html)
|
||||
|
||||
## Pending tests
|
||||
|
||||
In test suites of practice exercises, all but the first test have been tagged to be skipped.
|
||||
|
||||
Once you get a test passing, you can unskip the next one by commenting out the relevant `@tag :pending` with a `#` symbol.
|
||||
|
||||
For example:
|
||||
|
||||
```elixir
|
||||
# @tag :pending
|
||||
test "shouting" do
|
||||
assert Bob.hey("WATCH OUT!") == "Whoa, chill out!"
|
||||
end
|
||||
```
|
||||
|
||||
If you wish to run all tests at once, you can include all skipped test by using the `--include` flag on the `mix test` command:
|
||||
|
||||
```bash
|
||||
$ mix test --include pending
|
||||
```
|
||||
|
||||
Or, you can enable all the tests by commenting out the `ExUnit.configure` line in the file `test/test_helper.exs`.
|
||||
|
||||
```elixir
|
||||
# ExUnit.configure(exclude: :pending, trace: true)
|
||||
```
|
||||
|
||||
## Useful `mix test` options
|
||||
|
||||
* `test/<FILE>.exs:LINENUM` - runs only a single test, the test from `<FILE>.exs` whose definition is on line `LINENUM`
|
||||
* `--failed` - runs only tests that failed the last time they ran
|
||||
* `--max-failures` - the suite stops evaluating tests when this number of test failures
|
||||
is reached
|
||||
* `--seed 0` - disables randomization so the tests in a single file will always be ran
|
||||
in the same order they were defined in
|
||||
|
||||
## Submitting your solution
|
||||
|
||||
You can submit your solution using the `exercism submit lib/rna_transcription.ex` command.
|
||||
This command will upload your solution to the Exercism website and print the solution page's URL.
|
||||
|
||||
It's possible to submit an incomplete solution which allows you to:
|
||||
|
||||
- See how others have completed the exercise
|
||||
- Request help from a mentor
|
||||
|
||||
## Need to get help?
|
||||
|
||||
If you'd like help solving the exercise, check the following pages:
|
||||
|
||||
- The [Elixir track's documentation](https://exercism.org/docs/tracks/elixir)
|
||||
- The [Elixir track's programming category on the forum](https://forum.exercism.org/c/programming/elixir)
|
||||
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
|
||||
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
|
||||
|
||||
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
|
||||
|
||||
If you're stuck on something, it may help to look at some of the [available resources](https://exercism.org/docs/tracks/elixir/resources) out there where answers might be found.
|
|
@ -0,0 +1,70 @@
|
|||
# RNA Transcription
|
||||
|
||||
Welcome to RNA Transcription on Exercism's Elixir Track.
|
||||
If you need help running the tests or submitting your code, check out `HELP.md`.
|
||||
|
||||
## 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/
|
||||
~~~~
|
||||
|
||||
## 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.
|
||||
~~~~
|
||||
|
||||
## Source
|
||||
|
||||
### Created by
|
||||
|
||||
- @rubysolo
|
||||
|
||||
### Contributed to by
|
||||
|
||||
- @angelikatyborska
|
||||
- @Cohen-Carlisle
|
||||
- @dalexj
|
||||
- @devonestes
|
||||
- @drueck
|
||||
- @jinyeow
|
||||
- @lpil
|
||||
- @neenjaw
|
||||
- @parkerl
|
||||
- @pminten
|
||||
- @sotojuan
|
||||
- @Teapane
|
||||
- @tjcelaya
|
||||
- @veelenga
|
||||
- @waiting-for-dev
|
||||
|
||||
### Based on
|
||||
|
||||
Hyperphysics - https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html
|
|
@ -0,0 +1,17 @@
|
|||
defmodule RnaTranscription do
|
||||
@doc """
|
||||
Transcribes a character list representing DNA nucleotides to RNA
|
||||
|
||||
## Examples
|
||||
|
||||
iex> RnaTranscription.to_rna(~c"ACTG")
|
||||
~c"UGAC"
|
||||
"""
|
||||
@spec to_rna([char]) :: [char]
|
||||
def to_rna(?G), do: ?C
|
||||
def to_rna(?C), do: ?G
|
||||
def to_rna(?T), do: ?A
|
||||
def to_rna(?A), do: ?U
|
||||
def to_rna([char | rest]), do: [to_rna(char) | to_rna(rest)]
|
||||
def to_rna([]), do: []
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
defmodule RnaTranscription.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :rna_transcription,
|
||||
version: "0.1.0",
|
||||
# elixir: "~> 1.8",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
]
|
||||
end
|
||||
|
||||
# Run "mix help compile.app" to learn about applications.
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
# Run "mix help deps" to learn about dependencies.
|
||||
defp deps do
|
||||
[
|
||||
# {:dep_from_hexpm, "~> 0.3.0"},
|
||||
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
|
||||
]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
defmodule RnaTranscriptionTest do
|
||||
use ExUnit.Case
|
||||
|
||||
# @tag :pending
|
||||
test "empty RNA sequence" do
|
||||
assert RnaTranscription.to_rna(~c"") == ~c""
|
||||
end
|
||||
|
||||
test "transcribes guanine to cytosine" do
|
||||
assert RnaTranscription.to_rna(~c"G") == ~c"C"
|
||||
end
|
||||
|
||||
test "transcribes cytosine to guanine" do
|
||||
assert RnaTranscription.to_rna(~c"C") == ~c"G"
|
||||
end
|
||||
|
||||
test "transcribes thymidine to adenine" do
|
||||
assert RnaTranscription.to_rna(~c"T") == ~c"A"
|
||||
end
|
||||
|
||||
test "transcribes adenine to uracil" do
|
||||
assert RnaTranscription.to_rna(~c"A") == ~c"U"
|
||||
end
|
||||
|
||||
test "it transcribes all dna nucleotides to rna equivalents" do
|
||||
assert RnaTranscription.to_rna(~c"ACGTGGTCTTAA") == ~c"UGCACCAGAAUU"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
ExUnit.start()
|
||||
ExUnit.configure(exclude: :pending, trace: true)
|
Loading…
Reference in New Issue