Last active
December 21, 2015 23:18
-
-
Save ybur-yug/6380855 to your computer and use it in GitHub Desktop.
Nucleotide counter. Takes input of ATGC sequence form dna and returns number of each type in the string using basic regex and a hash. Epicodus exercise.
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
def nucleo_counter(sequence) | |
g = sequence.gsub(/[ATC]/, "").length | |
c = sequence.gsub(/[ATG]/, "").length | |
a = sequence.gsub(/[GCT]/, "").length | |
t = sequence.gsub(/[AGC]/, "").length | |
nucleotides = { | |
"A's" => a, | |
"T's" => t, | |
"G's" => g, | |
"C's" => c | |
} | |
puts nucleotides | |
end | |
nucleo_counter("ATCGATGCCCCAT") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment