예제 #1
0
        /// <summary>
        /// For each sequence read by the parser, pass it to the metric handler. Also update GUI summary panels
        /// </summary>
        private void ProcessSequences(string filename, BAMParser parser)
        {
            double incrementOne = 1; // the progress bar will update every [incrementOne] many clusters
            double incrementTwo = 1; // the progress bar will update every [incrementTwo] many clusters
            int increaseIncrementAfter = 100; // after this many clusters, increase the increment at which we update the gui
            double increment;       // the current increment at which progress bar will update
            int updateDisplayForClusterIndex = -1, clusterCount = -1; // whether we have already updated the gui for this cluster
            foreach (SAMAlignedSequence se in parser.ParseSequence(filename))
            {
                if (metricHandler.Add(se))
                {
                    clusterCount = metricHandler.ClusterCount;
                    increment = (clusterCount < increaseIncrementAfter) ? incrementOne : incrementTwo;
                    if ((clusterCount == 1 || (double)clusterCount % increment == 0) && clusterCount != updateDisplayForClusterIndex)
                    {
                        updateDisplayForClusterIndex = clusterCount;

                        Dispatcher.BeginInvoke(
                            System.Windows.Threading.DispatcherPriority.Normal,
                            new StatsDelegate(UpdateStatsPanel), metricHandler.GoodCount, clusterCount,
                                metricHandler.MaxSampleCount, metricHandler.MaxAlignmentQuality, metricHandler.MaxReadQuality,
                                metricHandler.AverageDirt, metricHandler.AverageMapQ, metricHandler.AverageReadQ,
                                metricHandler.AverageDirtGood, metricHandler.AverageMapQGood, metricHandler.AverageReadQGood);
                    }
                }
                else
                {
                    Console.WriteLine(Properties.Resources.HANDLER_FINISHED);
                    break;
                }
            }
            // Tell the handler that there are no more sequences to receive
            metricHandler.SetComplete();
        }