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); }
private void WriteHeader(List <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); }
/// <summary> /// constructor /// </summary> public CompressedSequenceWriter(string path, List <ReferenceMetadata> referenceMetadataList, ICytogeneticBands genomeCytobands, GenomeAssembly genomeAssembly) { _stream = FileUtilities.GetCreateStream(path); _writer = new ExtendedBinaryWriter(_stream); _refSeqIndex = new List <SequenceIndexEntry>(); _twoBitSequence = new TwoBitSequence(); _sequenceCompressor = new SequenceCompressor(); _refSeqMaskedIntervals = new List <List <MaskedEntry> >(); WriteHeader(referenceMetadataList, genomeCytobands, genomeAssembly); }
public CompressedSequenceWriter(Stream stream, IReadOnlyCollection <ReferenceMetadata> referenceMetadataList, ICytogeneticBands genomeCytobands, GenomeAssembly genomeAssembly) { _stream = stream; _writer = new ExtendedBinaryWriter(_stream); _refSeqNames = new List <string>(); _refSeqIndex = new List <SequenceIndexEntry>(); _twoBitSequence = new TwoBitSequence(); _sequenceCompressor = new SequenceCompressor(); _refSeqMaskedIntervals = new List <List <MaskedEntry> >(); WriteHeader(referenceMetadataList, genomeCytobands, genomeAssembly); }