Python work

This commit is contained in:
Brian Buller 2017-08-15 17:11:46 -05:00
parent d9b6cf9d91
commit 6899ed15fc
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# 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`
### Submitting Exercises
Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/<exerciseName>` directory.
For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit <path_to_exercism_dir>/python/bob/bob.py`.
For more detailed information about running tests, code style and linting,
please see the [help page](http://exercism.io/languages/python).
## 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.

View File

@ -0,0 +1,2 @@
def to_rna():
pass

View File

@ -0,0 +1,35 @@
import unittest
from rna_transcription import to_rna
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
class DNATests(unittest.TestCase):
def test_transcribes_guanine_to_cytosine(self):
self.assertEqual(to_rna('G'), 'C')
def test_transcribes_cytosine_to_guanine(self):
self.assertEqual(to_rna('C'), 'G')
def test_transcribes_thymine_to_adenine(self):
self.assertEqual(to_rna('T'), 'A')
def test_transcribes_adenine_to_uracil(self):
self.assertEqual(to_rna('A'), 'U')
def test_transcribes_all_occurences(self):
self.assertMultiLineEqual(to_rna('ACGTGGTCTTAA'), 'UGCACCAGAAUU')
def test_correctly_handles_single_invalid_input(self):
self.assertEqual(to_rna('U'), '')
def test_correctly_handles_completely_invalid_input(self):
self.assertMultiLineEqual(to_rna('XXX'), '')
def test_correctly_handles_partially_invalid_input(self):
self.assertMultiLineEqual(to_rna('ACGTXXXCTTAA'), '')
if __name__ == '__main__':
unittest.main()