public NucleotideSequence Complement() { if (String.IsNullOrEmpty(_rawComplement)) { _rawComplement = GetComplementString(); } //Transform the symbol counts table T count becomes A count, etc. var _newSymbolCounts = new Dictionary <Nucleotide, long>(SymbolCounts.Count); foreach (var symbol in SymbolCounts) { if (_newSymbolCounts.ContainsKey(symbol.Key)) { continue; } var nucleotide = symbol.Key; var countToBeSwapped = SymbolCounts[nucleotide]; var complement = ComplementTable[nucleotide]; var newCount = SymbolCounts[complement]; _newSymbolCounts.Add(nucleotide, newCount); _newSymbolCounts.Add(complement, countToBeSwapped); } if (GetType() == typeof(DnaSequence)) { return(DnaSequence.FastDnaSequence(_rawComplement, ActiveAlphabet, GeneticCode, _newSymbolCounts)); } return(RnaSequence.FastRnaSequence(_rawComplement, ActiveAlphabet, GeneticCode, _newSymbolCounts)); }
public override NucleotideSequence Transcribe() { var alphabet = ActiveAlphabet == AlphabetType.StrictRna ? AlphabetType.StrictDna : AlphabetType.AmbiguousDna; var newSymbolCounts = new Dictionary <Nucleotide, long>(SymbolCounts); var count = SymbolCounts[Nucleotide.Uracil]; newSymbolCounts.Remove(Nucleotide.Uracil); newSymbolCounts.Add(Nucleotide.Thymine, count); var newSequence = Sequence.Replace((char)Nucleotide.Uracil, (char)Nucleotide.Thymine); return(DnaSequence.FastDnaSequence(newSequence, alphabet, GeneticCode, newSymbolCounts)); }
public NucleotideSequence ReverseComplement() { if (String.IsNullOrEmpty(_rawComplement)) { _rawComplement = GetComplementString(); } var complementArray = _rawComplement.ToCharArray(); Array.Reverse(complementArray); var reversed = new string(complementArray); if (GetType() == typeof(DnaSequence)) { return(DnaSequence.FastDnaSequence(reversed, ActiveAlphabet, GeneticCode, SymbolCounts)); } else { return(RnaSequence.FastRnaSequence(reversed, ActiveAlphabet, GeneticCode, SymbolCounts)); } }
public ProteinSequence Translate(DnaSequence dna, AlphabetType desiredProteinAlphabet) { return(new ProteinSequence(dna)); }