Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
 public ProteinSequence Translate(DnaSequence dna, AlphabetType desiredProteinAlphabet)
 {
     return(new ProteinSequence(dna));
 }