Beispiel #1
0
        /// <summary>
        /// Helper method for retrieving the number of reads with symbol at position.
        /// </summary>
        /// <param name="symbol">The symbol of interest</param>
        /// <param name="position">Position in read sequence</param>
        /// <returns>Number of reads</returns>
        private int GetNumReadsAtPositionWithSymbol(byte symbol, int position)
        {
            int[] positions;

            if (SymbolCountByPositionTable.TryGetValue(symbol, out positions))
            {
                return(positions[position]);
            }
            else
            {
                return(0);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Iterate through each sequence and for each position, record the number of occurrences
        /// of each base symbol
        /// </summary>
        public override void ContentByPosition()
        {
            if (this.Sequences == null)
            {
                throw new ArgumentNullException("Sequences");
            }

            foreach (var seqObj in this.Sequences)
            {
                if (Worker != null && WorkerArgs != null && Worker.CancellationPending)
                {
                    WorkerArgs.Cancel = true;
                    break;
                }

                int p = 0;

                // iterate through each position in sequence string
                foreach (var symbol in seqObj)
                {
                    int[] positions;

                    // check if SymbolCountByPositionTable has this symbol initialized
                    if (SymbolCountByPositionTable.TryGetValue(symbol, out positions))
                    {
                        positions[p]++;
                        SymbolCountByPositionTable[symbol] = positions;
                    }
                    else
                    {
                        // initialize a new List for this symbol
                        SymbolCountByPositionTable.Add(symbol, new int[this.ReadLengthMax]);
                        SymbolCountByPositionTable[symbol][p] = 1;
                    }

                    p++;
                }
            }
            HasRunContentByPosition = true;
        }