Esempio n. 1
0
        private JasixNode FindFirstOverlappingNode(JasixNode searchNode)
        {
            var index = _nodes.BinarySearch(searchNode);

            if (index < 0)
            {
                index = ~index;
            }

            // if it is to the left of the first node, check if the end overlaps
            if (index == 0)
            {
                return(_nodes[index].Overlaps(searchNode) ? _nodes[index] : null);
            }

            if (index == _nodes.Count)
            {
                // if range overlaps the last node location of the last node, otherwise, -1
                return(_nodes[index - 1].Overlaps(searchNode) ? _nodes[index - 1] : null);
            }

            // if some intervals from the previous node overlaps the range
            if (_nodes[index - 1].Overlaps(searchNode))
            {
                return(_nodes[index - 1]);
            }

            return(_nodes[index].Overlaps(searchNode) ? _nodes[index] : null);
        }
Esempio n. 2
0
        public void Add(int begin, int end, long filePosition)
        {
            if (begin > end)
            {
                throw new UserErrorException($"start position {begin} is greater than end position{end}");
            }

            if (Utilities.IsLargeVariant(begin, end))
            {
                _largeVariants.Add(new Interval <long>(begin, end, filePosition));
                end = begin;// large variants will be recorded as snvs so that we can query for all entries from a given position
            }

            if (_currentNode == null)
            {
                _currentNode = new JasixNode(begin, end, filePosition);
                return;
            }

            if (_currentNode.TryAdd(begin, end))
            {
                return;
            }
            _nodes.Add(_currentNode);
            _currentNode = new JasixNode(begin, end, filePosition);
        }
Esempio n. 3
0
        public long FindFirstSmallVariant(int start, int end)
        {
            var searchNode = new JasixNode(start, end, 0);

            var firstOverlappingNode = FindFirstOverlappingNode(searchNode);

            return(firstOverlappingNode?.FileLocation ?? -1);
        }