// constructor
        public SupplementaryAnnotationReader(Stream dbStream, Stream idxStream, string saPath = null)
        {
            // open the database file
            _stream    = dbStream;
            _idxStream = idxStream;
            _reader    = new ExtendedBinaryReader(_stream);
            _index     = new SaIndex(new ExtendedBinaryReader(idxStream));

            // check the header
            Header = GetHeader(_reader, out _intervalsPosition, saPath);
        }
예제 #2
0
        // constructor
        public SupplementaryAnnotationWriter(string saPath, string currentRefSeq, List <DataSourceVersion> dataSourceVersions, GenomeAssembly genomeAssembly = GenomeAssembly.Unknown)
        {
            _dataSourceVersions    = dataSourceVersions;
            _saPath                = saPath;
            _currentRefSeq         = currentRefSeq;
            _currentGenomeAssembly = genomeAssembly;

            _stream = FileUtilities.GetCreateStream(saPath);
            _writer = new ExtendedBinaryWriter(_stream);
            _index  = new SaIndex();

            WriteHeader();
        }
        /// <summary>
        /// protected implementation of Dispose pattern.
        /// </summary>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                _stream.Dispose();
                _idxStream.Dispose();
            }

            _reader    = null;
            _stream    = null;
            _idxStream = null;
            _index     = null;
        }
예제 #4
0
        /// <summary>
        /// protected implementation of Dispose pattern.
        /// </summary>
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                // write a negative length
                _writer.WriteOpt(-1);


                // write the intervals
                WriteSupplementaryIntervals();

                // write the guard integer
                _writer.Flush();
                _eofOffset = _stream.Position;
                _writer.Write(SupplementaryAnnotationCommon.GuardInt);

                // update the offsets in the header
                _stream.Position = _offsetHeader;
                _writer.Write(_dataSourceVersionsOffset);
                _writer.Write(_dataOffset);
                _writer.Write(_intervalOffset);
                _writer.Write(_eofOffset);

                // close the file streams
                _writer.Dispose();
                _stream.Dispose();
                _index.Write(_saPath + ".idx", _currentRefSeq);
            }

            // reset all the class variables
            _stream = null;

            _dataSourceVersionsOffset = 0;
            _dataOffset     = 0;
            _eofOffset      = 0;
            _offsetHeader   = 0;
            _intervalOffset = 0;

            _index = null;
        }