示例#1
0
        public void Execute()
        {
            var readStatuses       = new ReadStatusCounter();
            var pairHandler        = CreatePairHandler(readStatuses);
            var stitcherPairFilter = new StitcherPairFilter(_options.FilterDuplicates,
                                                            _options.FilterForProperPairs, CreateDuplicateIdentifier(), readStatuses,
                                                            minMapQuality: _options.FilterMinMapQuality);

            Logger.WriteToLog(string.Format("Beginning execution of {0}.", _inBam + (_chrFilter != null ? ":" + _chrFilter : "")));

            using (var bamWriter = CreateBamWriter())
            {
                using (var bamReader = CreateBamReader())
                {
                    var rewriter = new BamRewriter(bamReader, bamWriter, stitcherPairFilter,
                                                   pairHandler, bufferSize: 100000, getUnpaired: _options.KeepUnpairedReads, chrFilter: _chrFilter);
                    rewriter.Execute();
                }
            }

            foreach (var readStatus in readStatuses.GetReadStatuses())
            {
                Logger.WriteToLog((_chrFilter ?? "") + " STATUSCOUNT " + readStatus.Key + ": " + readStatus.Value);
            }

            if (_options.Debug || _options.DebugSummary)
            {
                foreach (var readStatus in readStatuses.GetDebugReadStatuses())
                {
                    Logger.WriteToLog((_chrFilter ?? "") + " STATUSCOUNT " + readStatus.Key + ": " + readStatus.Value);
                }
            }

            Logger.WriteToLog(string.Format("Done writing filtered bam at '{0}'.", _outBam));
        }
示例#2
0
        public void Execute()
        {
            var readStatuses       = new ReadStatusCounter();
            var pairHandlers       = CreatePairHandlers(readStatuses, _options.NumThreads);
            var stitcherPairFilter = new StitcherPairFilter(_options.FilterDuplicates,
                                                            _options.FilterForProperPairs, CreateDuplicateIdentifier(), readStatuses,
                                                            minMapQuality: _options.FilterMinMapQuality, filterPairUnmapped: _options.FilterPairUnmapped, filterPairLowMapQ: _options.FilterPairLowMapQ);

            BlockingCollection <Task> taskQueue = null;
            ThreadPool threadPool = null;

            if (_options.NumThreads > 1)
            {
                taskQueue  = new BlockingCollection <Task>(4 * _options.NumThreads);
                threadPool = new ThreadPool(taskQueue, _options.NumThreads);
            }

            Logger.WriteToLog(string.Format("Beginning execution of {0}.", _inBam + (_chrFilter != null ? ":" + _chrFilter : "")));

            using (var bamWriter = CreateBamWriter())
            {
                using (var bamReader = CreateBamReader())
                {
                    var rewriter = new BamRewriter(bamReader, bamWriter, stitcherPairFilter,
                                                   pairHandlers, taskQueue, getUnpaired: _options.KeepUnpairedReads, chrFilter: _chrFilter);
                    rewriter.Execute();
                }

                threadPool?.RunToCompletion();

                foreach (var pairHandler in pairHandlers)
                {
                    pairHandler.Finish();
                }

                Logger.WriteToLog("Finished stitching. Starting sort and write.");
                bamWriter.Flush();
            }

            foreach (var readStatus in readStatuses.GetReadStatuses())
            {
                Logger.WriteToLog((_chrFilter ?? "") + " STATUSCOUNT " + readStatus.Key + ": " + readStatus.Value);
            }

            if (_options.Debug || _options.DebugSummary)
            {
                foreach (var readStatus in readStatuses.GetDebugReadStatuses())
                {
                    Logger.WriteToLog((_chrFilter ?? "") + " STATUSCOUNT " + readStatus.Key + ": " + readStatus.Value);
                }
            }

            Logger.WriteToLog(string.Format("Done writing filtered bam at '{0}'.", _outBam));
        }