-
-
Save julia-/c384ff8b6689a7c2993a to your computer and use it in GitHub Desktop.
Revisions
-
threequal renamed this gist
Feb 24, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
threequal created this gist
Feb 24, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ # Nucleotide Count DNA is represented by an alphabet of the following symbols: 'A', 'C', 'G', and 'T'. Each symbol represents a nucleotide, which is a fancy name for the particular molecules that happen to make up a large part of DNA. Shortest intro to biochemistry EVAR: * twigs are to birds nests as * nucleotides are to DNA and RNA as * amino acids are to proteins as * sugar is to starch as * oh crap lipids I'm not going to talk about lipids because they're crazy complex. So back to DNA. Write a class `DNA` that takes a DNA string. It should have two ways of telling us how many times each nucleotide occurs in the string: `#count(nucleotide)` and `#nucleotide_count`. ```ruby dna = DNA.new("ATGCTTCAGAAAGGTCTTACG") dna.count('A') # => 6 dna.count('T') # => 6 dna.count('G') # => 5 dna.count('C') # => 4 dna.count('U') # Uracil is a nucleotide that is used in RNA # => 0 dna.nucleotide_counts # => {'A' => 6, 'T' => 6, 'G' => 5, 'C' => 4} ``` The code should raise an argument error if you try to count something that isn't a nucleotide. ```ruby dna.count('S') # dna.rb:23:in 'count': That's not a nucleotide, silly! (ArgumentError) ``` ## Sample Dataset ```ruby s = "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC" dna = DNA.new(s) dna.nucleotide_counts # => {'A' => 20, 'T' => 21, 'G' => 17, 'C' => 12} ``` ## Source The _Calculating DNA Nucleotides_ problem at [Rosalind](http://rosalind.info/problems/dna/)