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.StrictDna ? AlphabetType.StrictRna : AlphabetType.AmbiguousRna;
            var newSymbolCounts = new Dictionary <Nucleotide, long>(SymbolCounts);
            var count           = SymbolCounts[Nucleotide.Thymine];

            newSymbolCounts.Remove(Nucleotide.Thymine);
            newSymbolCounts.Add(Nucleotide.Uracil, count);
            var newSequence = Sequence.Replace((char)Nucleotide.Thymine, (char)Nucleotide.Uracil);

            return(RnaSequence.FastRnaSequence(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));
            }
        }