Esempio 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);
                }
        }
Esempio n. 2
0
        private void WritePosition(List <ISupplementaryDataItem> saItems)
        {
            var refMinorItem = (RefMinorItem)GetRefMinorItem(saItems);

            if (refMinorItem == null)
            {
                return;
            }

            _refMinorIndex.Add(refMinorItem.Chromosome.Index, _stream.Position);
            _writer.WriteOpt(refMinorItem.Position);
            _writer.WriteOptAscii(refMinorItem.GlobalMajor);
        }
Esempio 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);
            }
        }