예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        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);
        }