public void Query_chunks_in_same_chrom() { var stream = new MemoryStream(); var writer = new ExtendedBinaryWriter(stream); var version = new DataSourceVersion("dbsnp", "150", DateTime.Now.Ticks, "dbsnp ids"); var index = new ChunkedIndex(writer, GenomeAssembly.GRCh37, version, "dbsnp", true, true, SaCommon.SchemaVersion, false); index.Add(0, 100, 2000, 23457, 89320); index.Add(0, 2100, 4000, 112778, 58746); index.Add(0, 4100, 7000, 171525, 658794); (long start, int chunkCount) = index.GetFileRange(0, 150, 2120); Assert.Equal(23457, start); Assert.Equal(2, chunkCount); (start, chunkCount) = index.GetFileRange(0, 50, 98); Assert.Equal(-1, start); Assert.Equal(0, chunkCount); (start, chunkCount) = index.GetFileRange(0, 150, 2010); Assert.Equal(23457, start); Assert.Equal(1, chunkCount); (start, chunkCount) = index.GetFileRange(0, 2010, 4050); Assert.Equal(112778, start); Assert.Equal(1, chunkCount); (start, chunkCount) = index.GetFileRange(0, 4010, 4050); Assert.Equal(-1, start); Assert.Equal(0, chunkCount); (start, chunkCount) = index.GetFileRange(0, 7010, 7050); Assert.Equal(-1, start); Assert.Equal(0, chunkCount); }
//todo: filter chromIndex=ushort.Max public NsaWriter(ExtendedBinaryWriter writer, ExtendedBinaryWriter indexWriter, DataSourceVersion version, ISequenceProvider refProvider, string jsonKey, bool matchByAllele, bool isArray, int schemaVersion, bool isPositional, bool skipIncorrectRefEntries = true, bool throwErrorOnConflicts = false, int blockSize = SaCommon.DefaultBlockSize) { _stream = writer.BaseStream; _writer = writer; _isPositional = isPositional; _skipIncorrectRefEntries = skipIncorrectRefEntries; _throwErrorOnConflicts = throwErrorOnConflicts; _block = new NsaBlock(new Zstandard(), blockSize); _refProvider = refProvider; _index = new ChunkedIndex(indexWriter, refProvider.Assembly, version, jsonKey, matchByAllele, isArray, schemaVersion, isPositional); _memBuffer = new byte[short.MaxValue * 2]; _memStream = new MemoryStream(_memBuffer); _memWriter = new ExtendedBinaryWriter(_memStream); }