Exemplo n.º 1
0
        public void PreLoad(IChromosome chrom, List <int> positions)
        {
            if (positions == null || positions.Count == 0)
            {
                return;
            }

            _annotations.Clear();
            for (var i = 0; i < positions.Count; i++)
            {
                int  position     = positions[i];
                long fileLocation = _index.GetFileLocation(chrom.Index, position);
                if (fileLocation == -1)
                {
                    continue;
                }

                //only reconnect if necessary
                if (_reader.BaseStream.Position != fileLocation)
                {
                    _reader.BaseStream.Position = fileLocation;
                }
                _block.Read(_reader);
                int lastLoadedPositionIndex = LoadAnnotations(positions, i);
                //if there were any positions in the block, the index will move ahead.
                // we need to decrease it by 1 since the loop will increment it.
                if (lastLoadedPositionIndex > i)
                {
                    i = lastLoadedPositionIndex - 1;
                }
            }
        }
Exemplo n.º 2
0
        public void PreLoad(IChromosome chrom, List <int> positions)
        {
            if (positions == null || positions.Count == 0)
            {
                return;
            }

            _annotations.Clear();
            for (var i = 0; i < positions.Count;)
            {
                int  position     = positions[i];
                long fileLocation = _index.GetFileLocation(chrom.Index, position);
                if (fileLocation == -1)
                {
                    i++;
                    continue;
                }

                //only reconnect if necessary
                if (_reader.BaseStream.Position != fileLocation)
                {
                    _reader.BaseStream.Position = fileLocation;
                }
                _block.Read(_reader);
                var newIndex = _block.AddAnnotations(positions, i, _annotations);
                if (newIndex == i)
                {
                    i++;                //no positions were found in this block
                }
                else
                {
                    i = newIndex;
                }
            }
        }