/// <summary>
 /// Constructs a Block of aligned sequences
 /// (<see cref="QUT.Bio.BioPatML.Patterns.PWM"> PWM </see>).
 /// </summary>
 /// <param name="name">Name for element block</param>
 /// <param name="sequenceList"> List of aligned sequences. </param>
 /// <param name="background"> Histogram with base counts of the background
 /// sequences.</param>
 /// <param name="threshold"> Similarity threshold. </param>
 public Block
     (String name, SequenceList sequenceList,
         HistogramSymbol background, double threshold)
     : base(name, sequenceList[0].Alphabet, threshold)
 {
     Estimate(sequenceList, background);
 }
        /** Tests the adding of a histogram to the histogram */
        public void TestAddHistogram()
        {
            HistogramSymbol histo2 = new HistogramSymbol();
            histo.Add(new Sequence(AlphabetType.DNA, "gactt"));
            histo2.Add(new Sequence(AlphabetType.DNA, "act"));
            histo.Add(histo2);

            Assert.AreEqual(2, histo.HistoValue(alpha['a']));
            Assert.AreEqual(2, histo.HistoValue(alpha['c']));
            Assert.AreEqual(3, histo.HistoValue(alpha['t']));
            Assert.AreEqual(1, histo.HistoValue(alpha['g']));
        }
        /// <summary>
        /// Estimates the weights of the PWM that's behind a Block pattern.
        /// </summary>
        /// <exception cref="System.ArgumentException">
        /// Thrown when sequences length are not equal</exception>
        /// <param name="sequenceList"> List of aligned sequences. </param>
        /// <param name="background"> Histogram with base counts of the background
        /// sequences. Can be null. In that case all frequencies are set equally.</param>
        private void Estimate
            (SequenceList sequenceList, HistogramSymbol background)
        {
            int length = sequenceList.MinLength();

            if (sequenceList.MaxLength() != length)
                throw new ArgumentException
                    ("Sequences must be of equal length!");

            if (background == null)
            {
                background = new HistogramSymbol();

                foreach (Symbol sym in PWMalphabet)
                    background.Add(sym);
            }

            base.Init(length);
            base.Estimate(sequenceList, 1, background);
        }
 /// <summary>
 ///  Adds all symbols and their frequencies of the given histogram to this histogram.
 /// </summary>
 /// <param name="histogram"> A symbol histogram. </param>
 public void Add(HistogramSymbol histogram)
 {
     for (int i = 0; i < histogram.Count; i++)
     {
         Symbol symbol = histogram[i];
         Add(symbol, histogram.HistoValue(i));
     }
 }
 public void Setup()
 {
     histo = new HistogramSymbol();
     alpha = AlphabetFactory.Instance(AlphabetType.DNA);
 }