public void Serialization() { ICytogeneticBands expectedCytogeneticBands = GetCytogeneticBands(); ICytogeneticBands observedCytogeneticBands; using (var ms = new MemoryStream()) { using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true)) { expectedCytogeneticBands.Write(writer); } ms.Seek(0, SeekOrigin.Begin); using (var reader = new ExtendedBinaryReader(ms)) { var bands = CytogeneticBands.Read(reader); observedCytogeneticBands = new CytogeneticBands(bands, _renamer); } } var expectedCytogeneticBand = expectedCytogeneticBands.GetCytogeneticBand(10, 88400000, 92900000); var observedCytogeneticBand = observedCytogeneticBands.GetCytogeneticBand(10, 88400000, 92900000); Assert.NotNull(observedCytogeneticBand); Assert.Equal(expectedCytogeneticBand, observedCytogeneticBand); }
/// <summary> /// loads the header /// </summary> private void LoadHeader() { // grab the index and masked intervals offsets _indexOffset = _reader.ReadInt64(); _maskedIntervalsOffset = _reader.ReadInt64(); // skip the creation time _reader.ReadOptInt64(); // grab the reference metadata int numRefSeqs = _reader.ReadOptInt32(); for (int i = 0; i < numRefSeqs; i++) { Metadata.Add(ReferenceMetadata.Read(_reader)); } // update the chromosome renamer _compressedSequence.Renamer.AddReferenceMetadata(Metadata); // read the cytogenetic bands _compressedSequence.CytogeneticBands = new CytogeneticBands(CytogeneticBands.Read(_reader), _compressedSequence.Renamer); // read the genome assembly _compressedSequence.GenomeAssembly = (GenomeAssembly)_reader.ReadByte(); // grab the data start tag ulong dataStartTag = _reader.ReadUInt64(); if (dataStartTag != CompressedSequenceCommon.DataStartTag) { throw new UserErrorException($"The data start tag does not match the expected values: Obs: {dataStartTag} vs Exp: {CompressedSequenceCommon.DataStartTag}"); } _dataStartOffset = _stream.Position; }