Exemplo n.º 1
0
        /// <summary>
        /// Constructs sequence statistics by iterating through a list of sequences.
        /// </summary>
        /// <param name="sequences">The list of sequences to construct statistics for.</param>
        internal SequenceStatistics(IList <ISequence> sequences)
        {
            _alphabet = sequences[0].Alphabet;

            _countHash  = new Dictionary <char, int>();
            _totalCount = 0;

            foreach (ISequence seq in sequences)
            {
                SequenceStatistics seqStats = seq.Statistics;

                if (seqStats._alphabet != _alphabet)
                {
                    throw new Exception("Cannot create statistics for list of sequences with different alphabets.");
                }

                foreach (char symbol in seqStats._countHash.Keys)
                {
                    if (_countHash.ContainsKey(symbol))
                    {
                        _countHash[symbol] += seqStats._countHash[symbol];
                    }
                    else
                    {
                        _countHash.Add(symbol, seqStats._countHash[symbol]);
                    }
                }

                _totalCount += seqStats._totalCount;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="that">The sequence statistics to copy from.</param>
        internal SequenceStatistics(SequenceStatistics that)
        {
            _alphabet = that._alphabet;

            _countHash = new Dictionary <char, int>();
            foreach (char symbol in that._countHash.Keys)
            {
                _countHash.Add(symbol, that._countHash[symbol]);
            }

            _totalCount = that._totalCount;
        }