new rna_transcription.rb according to comments
This commit is contained in:
parent
a177b61678
commit
d8f97adbaf
|
@ -1,15 +1,15 @@
|
||||||
class Complement
|
class Complement
|
||||||
|
PAIRS = {
|
||||||
|
"A" => "U",
|
||||||
|
"T" => "A",
|
||||||
|
"C" => "G",
|
||||||
|
"G" => "C"
|
||||||
|
}
|
||||||
|
|
||||||
def self.of_dna(dna)
|
def self.of_dna(dna)
|
||||||
pairs = {
|
|
||||||
"A" => "U",
|
|
||||||
"T" => "A",
|
|
||||||
"C" => "G",
|
|
||||||
"G" => "C"
|
|
||||||
}
|
|
||||||
dna.each_char.reduce("") do |memo, char|
|
dna.each_char.reduce("") do |memo, char|
|
||||||
return "" unless pairs.member?(char)
|
break "" unless PAIRS.key?(char)
|
||||||
memo + pairs[char]
|
memo + PAIRS[char]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue