Sha256: 3d7aa71c88876c392fbc9ea93aeca31494b56be6b821c8c6f3ee59d8ad2a5764
Contents?: true
Size: 754 Bytes
Versions: 258
Compression:
Stored size: 754 Bytes
Contents
using System; using System.Collections.Generic; public class DNA { public IDictionary<char, int> NucleotideCounts { get; private set; } public DNA(string sequence) { InitializeNucleotideCounts(sequence); } private void InitializeNucleotideCounts(string sequence) { NucleotideCounts = new Dictionary<char, int> { { 'A', 0 }, { 'T', 0 }, { 'C', 0 }, { 'G', 0 } }; foreach (var s in sequence) NucleotideCounts[s] += 1; } public int Count(char nucleotide) { int count; if (!NucleotideCounts.TryGetValue(nucleotide, out count)) throw new InvalidNucleotideException(); return count; } } public class InvalidNucleotideException : Exception { }
Version data entries
258 entries across 258 versions & 1 rubygems