Exemplo n.º 1
0
        public void Compress(string bases, TwoBitSequence twoBitSequence)
        {
            twoBitSequence.Allocate(bases.Length);
            byte num1   = 0;
            var  index1 = 0;
            var  num2   = 0;

            foreach (char index2 in bases)
            {
                byte num3 = _convertBaseToNumber[index2];
                if (num3 == 10)
                {
                    num3 = 0;
                }
                num1 = (byte)((uint)num1 << 2 | num3);
                ++num2;

                if (num2 != 4)
                {
                    continue;
                }

                twoBitSequence.Buffer[index1] = num1;
                num1 = 0;
                num2 = 0;
                ++index1;
            }

            if (num2 != 0)
            {
                twoBitSequence.Buffer[index1] = (byte)((uint)num1 << (4 - num2) * 2);
            }

            for (var index2 = 0; index2 < bases.Length; ++index2)
            {
                if (bases[index2] != 'N')
                {
                    continue;
                }

                int begin = index2;
                int end   = index2;

                for (++index2; index2 < bases.Length && bases[index2] == 'N'; ++index2)
                {
                    end = index2;
                }

                var maskedEntry = new MaskedEntry(begin, end);
                twoBitSequence.MaskedIntervals.Add(maskedEntry);
            }
        }
Exemplo n.º 2
0
        public CompressedSequenceWriter(Stream stream, IReadOnlyCollection <ReferenceMetadata> referenceMetadataList,
                                        ISerializable 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);
        }
Exemplo n.º 3
0
        private void Dispose(bool disposing)
        {
            if (disposing)
            {
                WriteReferenceSequenceIndex();
                WriteMaskedIntervals();
                WriteEofTag();
                _stream.Dispose();
            }

            _refSeqIndex           = null;
            _refSeqMaskedIntervals = null;
            _twoBitSequence        = null;
            _sequenceCompressor    = null;

            _headerDataOffset      = 0L;
            _indexOffset           = 0L;
            _maskedIntervalsOffset = 0L;
        }