public void Dispose()
        {
            if (_writer != null)
            {
                _writer.Close();
                _writer.Dispose();

                _writer = null;
            }
        }
예제 #2
0
        public void FinishAll()
        {
            FlushAllBufferedRecords();

            _bamWriter.Close();
            _bamWriter.Dispose();

            using (var writer = GetWriter(_temp2File))
            {
                AdjustMates(_temp1File, writer);
                if (_copyUnaligned)
                {
                    WriteUnalignedReads(writer);
                }
            }

            if (_createIndex)
            {
                Logger.WriteToLog("Creating index");
                new BamIndex().CreateIndexFromBamFile(_temp2File);
                Logger.WriteToLog("Completed creating index");
            }

            // if everything goes well, rename to final destination
            File.Delete(_temp1File);
            File.Delete(_outputFile);

            File.Move(_temp2File, _outputFile);
            if (_createIndex)
            {
                var outputBaiFile = _outputFile + ".bai";
                File.Delete(outputBaiFile);

                File.Move(_temp2File + ".bai", outputBaiFile);
            }
        }