Ejemplo n.º 1
0
        public void CreateAndQuery_multiple_chromosomes()
        {
            using (var stream = new MemoryStream())
                using (var writer = new ExtendedBinaryWriter(stream))
                {
                    var index = new RefMinorIndex(writer, GenomeAssembly.GRCh37, new DataSourceVersion("name", "1", DateTime.Now.Ticks), SaCommon.SchemaVersion);

                    index.Add(0, 100);
                    index.Add(0, 105);
                    index.Add(0, 110);
                    index.Add(0, 115);
                    index.Add(1, 200);
                    index.Add(1, 205);
                    index.Add(1, 210);
                    index.Add(2, 315);

                    index.Write(320);

                    (long location, int byteCount, int count) = index.GetFileRange(0);
                    Assert.Equal(100, location);
                    Assert.Equal(100, byteCount);
                    Assert.Equal(4, count);

                    (location, byteCount, count) = index.GetFileRange(1);
                    Assert.Equal(200, location);
                    Assert.Equal(115, byteCount);
                    Assert.Equal(3, count);

                    (location, byteCount, count) = index.GetFileRange(2);
                    Assert.Equal(315, location);
                    Assert.Equal(5, byteCount);
                    Assert.Equal(1, count);
                }
        }
Ejemplo n.º 2
0
 public RefMinorDbWriter(ExtendedBinaryWriter writer, ExtendedBinaryWriter indexWriter, DataSourceVersion version, ISequenceProvider refProvider, int schemaVersion)
 {
     _stream        = writer.BaseStream;
     _writer        = writer;
     _refProvider   = refProvider;
     _refMinorIndex = new RefMinorIndex(indexWriter, _refProvider.Assembly, version, schemaVersion);
 }
Ejemplo n.º 3
0
        public void ReadBack()
        {
            var stream = new MemoryStream();

            using (var writer = new ExtendedBinaryWriter(stream))
            {
                var index = new RefMinorIndex(writer, GenomeAssembly.GRCh37, new DataSourceVersion("name", "1", DateTime.Now.Ticks), SaCommon.SchemaVersion);

                index.Add(0, 100);
                index.Add(0, 105);
                index.Add(0, 110);
                index.Add(0, 115);
                index.Add(1, 200);
                index.Add(1, 205);
                index.Add(1, 210);
                index.Add(2, 315);

                index.Write(320);
            }
            var readStream = new MemoryStream(stream.ToArray())
            {
                Position = 0
            };

            using (var reader = new ExtendedBinaryReader(readStream))
            {
                var index = new RefMinorIndex(reader);
                (long location, int byteCount, int count) = index.GetFileRange(0);
                Assert.Equal(100, location);
                Assert.Equal(100, byteCount);
                Assert.Equal(4, count);

                (location, byteCount, count) = index.GetFileRange(1);
                Assert.Equal(200, location);
                Assert.Equal(115, byteCount);
                Assert.Equal(3, count);

                (location, byteCount, count) = index.GetFileRange(2);
                Assert.Equal(315, location);
                Assert.Equal(5, byteCount);
                Assert.Equal(1, count);
            }
        }