Last active
August 29, 2015 14:14
-
-
Save revdan/acabe722284f512324d7 to your computer and use it in GitHub Desktop.
exercism.io Rna Transcription
This file contains 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
class Complement | |
def self.of_dna(dna) | |
dna.chars.map { |char| transpositions[char] }.join | |
end | |
def self.of_rna(rna) | |
rna.chars.map { |char| transpositions.invert[char] }.join | |
end | |
private | |
def self.transpositions | |
{ CYTOSINE => GUANINE, GUANINE => CYTOSINE, THYMINE => ADENINE, ADENINE => URACIL } | |
end | |
CYTOSINE = 'C' | |
GUANINE = 'G' | |
ADENINE = 'A' | |
THYMINE = 'T' | |
URACIL = 'U' | |
end |
This file contains 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
require 'minitest/autorun' | |
require_relative 'complement' | |
class ComplementTest < MiniTest::Unit::TestCase | |
def test_rna_complement_of_cytosine_is_guanine | |
assert_equal 'G', Complement.of_dna('C') | |
end | |
def test_rna_complement_of_guanine_is_cytosine | |
skip | |
assert_equal 'C', Complement.of_dna('G') | |
end | |
def test_rna_complement_of_thymine_is_adenine | |
skip | |
assert_equal 'A', Complement.of_dna('T') | |
end | |
def test_rna_complement_of_adenine_is_uracil | |
skip | |
assert_equal 'U', Complement.of_dna('A') | |
end | |
def test_rna_complement | |
skip | |
assert_equal 'UGCACCAGAAUU', Complement.of_dna('ACGTGGTCTTAA') | |
end | |
def test_dna_complement_of_cytosine_is_guanine | |
skip | |
assert_equal 'G', Complement.of_rna('C') | |
end | |
def test_dna_complement_of_guanine_is_cytosine | |
skip | |
assert_equal 'C', Complement.of_rna('G') | |
end | |
def test_dna_complement_of_uracil_is_adenine | |
skip | |
assert_equal 'A', Complement.of_rna('U') | |
end | |
def test_dna_complement_of_adenine_is_thymine | |
skip | |
assert_equal 'T', Complement.of_rna('A') | |
end | |
def test_dna_complement | |
skip | |
assert_equal 'ACTTGGGCTGTAC', Complement.of_rna('UGAACCCGACAUG') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment