Ejemplo n.º 1
0
        public NsaReader(Stream dataStream, Stream indexStream, int blockSize = SaCommon.DefaultBlockSize)
        {
            _stream    = dataStream;
            _blockSize = blockSize;
            _reader    = new ExtendedBinaryReader(_stream);
            _block     = new NsaBlock(new Zstandard(), blockSize);

            _index        = new NsaIndex(indexStream);
            Assembly      = _index.Assembly;
            Version       = _index.Version;
            JsonKey       = _index.JsonKey;
            MatchByAllele = _index.MatchByAllele;
            IsArray       = _index.IsArray;
            IsPositional  = _index.IsPositional;

            if (_index.SchemaVersion != SaCommon.SchemaVersion)
            {
                throw new UserErrorException($"SA schema version mismatch. Expected {SaCommon.SchemaVersion}, observed {_index.SchemaVersion} for {JsonKey}");
            }

            _annotations      = new List <AnnotationItem>(64 * 1024);
            _annotationBuffer = new byte[1024 * 1024];
            _annotationStream = new MemoryStream(_annotationBuffer);
            _annotationReader = new ExtendedBinaryReader(_annotationStream);
        }