Example #1
0
        /// <summary>
        /// Trims the color data, adjust peak locations and data based on the new residue range.
        /// </summary>
        /// <param name = "startIndex">Starting residue to include.</param>
        /// <param name = "length">Number of residues to trim to.</param>
        public void Trim(int startIndex, int length)
        {
            if (startIndex < 0 || DataByResidue.Count <= startIndex)
            {
                throw new ArgumentException(Resource.ColorDataTrimStartIndexOutOfRange, "startIndex");
            }
            if (startIndex + length > DataByResidue.Count)
            {
                throw new ArgumentException(Resource.ColorDataTrimLengthArgumentException, "length");
            }

            DataByResidue = new List <Ab1ResidueColorData>(
                DataByResidue.GetRange(startIndex, length));
            LoadMaxValue();
        }
Example #2
0
        /// <summary>
        /// Adds a new color data definition fora residue to <see cref="DataByResidue"/>.
        /// </summary>
        /// <param name="peakIndex"></param>
        /// <param name="residueDataIndex"></param>
        /// <param name="residueEndIndex"></param>
        /// <param name="data"></param>
        private void AddResidueColorData(int peakIndex, int residueDataIndex, int residueEndIndex, short[] data)
        {
            var residueColorData =
                new Ab1ResidueColorData
            {
                //
                // There appears to be situations in AB1 files where 2 residues share the same peak index, this breaks the logic below by assigning
                // the peakindex a negative value, so we can avoid that by maxing to 0.
                //

                PeakIndex = Math.Max(0, peakIndex - residueDataIndex),
                Data      = data.GetRange(residueDataIndex, residueEndIndex - residueDataIndex + 1)
            };

            DataByResidue.Add(residueColorData);
        }
Example #3
0
 /// <summary>
 /// Calculates and stores the max peak value.
 /// </summary>
 private void LoadMaxValue()
 {
     Max = 0;
     DataByResidue.ForEach(item => Max = Math.Max(Max, item.PeakValue));
 }