public NucleotideAlphabet(AlphabetType nucleotideAlphabet, GeneticCode geneticCode) { if (nucleotideAlphabet == AlphabetType.ExtendedProtein || nucleotideAlphabet == AlphabetType.StandardProtein) { throw new ArgumentException(String.Format(AlphabetDataProvider.InvalidNucleotideAlphabet, nucleotideAlphabet)); } GeneticCode = geneticCode; AllowedSymbols = AlphabetDataProvider.GetAllowedNucleotideSymbols(nucleotideAlphabet); ComplementTable = AlphabetDataProvider.GetComplementTable(nucleotideAlphabet); TranscriptionTable = AlphabetDataProvider.GetTranscriptionTable(nucleotideAlphabet); TranslationTable = AlphabetDataProvider.GetTranslationTable(geneticCode, nucleotideAlphabet); GcContentSymbols = AlphabetDataProvider.GcContentSymbols(nucleotideAlphabet); }
internal ProteinSequence(NucleotideSequence seq) { if (seq.ActiveAlphabet == AlphabetType.StrictDna || seq.ActiveAlphabet == AlphabetType.StrictRna) { if (seq.Sequence.Length % 3 != 0) { throw new ArgumentException("Sequence length is not evenly divisible by three, which means it cannot be translated because you are using a strict nucleotide alphabet"); } } AlphabetType alphabet; var allowedSymbols = new HashSet <AminoAcid> { AminoAcid.Stop, AminoAcid.Gap }; switch (seq.ActiveAlphabet) { case AlphabetType.AmbiguousDna: alphabet = AlphabetType.ExtendedProtein; allowedSymbols.UnionWith(AlphabetDataProvider.ExtendedProtein); break; case AlphabetType.AmbiguousRna: alphabet = AlphabetType.ExtendedProtein; allowedSymbols.UnionWith(AlphabetDataProvider.ExtendedProtein); break; default: alphabet = AlphabetType.StandardProtein; allowedSymbols.UnionWith(AlphabetDataProvider.StandardProtein); break; } var translationTable = new Dictionary <string, AminoAcid>(AlphabetDataProvider.GetTranslationTable(seq.GeneticCode, seq.ActiveAlphabet)); //string safeSequence, AlphabetType alphabet, GeneticCode geneticCode, Dictionary<Nucleotide, long> symbolCounts ActiveAlphabet = seq.ActiveAlphabet; _proteinAlphabet = new ProteinAlphabet(alphabet, seq.GeneticCode); var proteinBlob = Translate(seq.Sequence, translationTable); Sequence = proteinBlob.Sequence; _aminoCounts = proteinBlob.AminoCounts; }