private static IAminoAcid ToAminoAcid(INucleobase nb1, INucleobase nb2, INucleobase nb3) { string tripletCode = new string(new char[3] { nb1.Letter, nb2.Letter, nb3.Letter }); Func <IAminoAcid> func = CodonTable[tripletCode]; return(func()); }
public static Protein ToProtein(ISequence <INucleobase> nucleobaseChain) { Debug.Assert(nucleobaseChain.Count % 3 == 0); var protein = new Protein(); IEnumerator <INucleobase> enumerator = nucleobaseChain.GetEnumerator(); while (enumerator.MoveNext()) { INucleobase nb1 = enumerator.Current; enumerator.MoveNext(); INucleobase nb2 = enumerator.Current; enumerator.MoveNext(); INucleobase nb3 = enumerator.Current; IAminoAcid aa = ToAminoAcid(nb1, nb2, nb3); protein.Add(aa); } return(protein); }
private static INucleobase ToRna(INucleobase nucleobase) { if (nucleobase.Letter == Adenine.LetterCode) { return(new Adenine()); } if (nucleobase.Letter == Cytosine.LetterCode) { return(new Cytosine()); } if (nucleobase.Letter == Guanine.LetterCode) { return(new Guanine()); } if (nucleobase.Letter == Thymine.LetterCode) { return(new Uracil()); } throw Exception(); }