private void WriteHeader(IReadOnlyCollection <ReferenceMetadata> referenceMetadataList, ICytogeneticBands genomeCytobands, GenomeAssembly genomeAssembly) { _writer.Write(CompressedSequenceCommon.HeaderTag); _writer.Write(CompressedSequenceCommon.HeaderVersion); _writer.Flush(); _headerDataOffset = _stream.Position; // grab the index and masked intervals offsets _writer.Write(_indexOffset); _writer.Write(_maskedIntervalsOffset); // grab the creation time _writer.WriteOpt(DateTime.UtcNow.Ticks); // write the reference metadata _writer.WriteOpt(referenceMetadataList.Count); foreach (var refMetadata in referenceMetadataList) { refMetadata.Write(_writer); } // write the genome cytobands genomeCytobands.Write(_writer); // write the genome assembly _writer.Write((byte)genomeAssembly); // write the data start tag _writer.Write(CompressedSequenceCommon.DataStartTag); }
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); }