Exemplo n.º 1
0
        // ReSharper disable once UnusedMember.Global
        public bool HasVariants(string chromosomeName, int begin, int end)
        {
            var refSeq = _index.GetTabixReferenceSequence(chromosomeName);

            if (refSeq == null)
            {
                return(false);
            }

            int adjBegin = SearchUtilities.AdjustBegin(begin);

            IEnumerable <int> bins = BinUtilities.OverlappingBinsWithVariants(adjBegin, end, refSeq.IdToChunks);

            var block = new BgzfBlock();

            foreach (int bin in bins)
            {
                refSeq.IdToChunks.TryGetValue(bin, out Interval[] chunks);
                if (HasVariantsInBin(refSeq.Chromosome, begin, end, block, chunks))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool HasVariants(string chromosomeName, int begin, int end)
        {
            var refSeq = _index.GetTabixReferenceSequence(chromosomeName);

            if (refSeq == null)
            {
                return(false);
            }

            int adjBegin = SearchUtilities.AdjustBegin(begin);

            int beginBin = BinUtilities.ConvertPositionToBin(adjBegin);
            int endBin   = BinUtilities.ConvertPositionToBin(end);

            int binDiff = endBin - beginBin;

            // we can use the tabix index to investigate if any of the internal bins have variants
            if (binDiff >= 2)
            {
                bool hasInternalVariants = HasVariantsInAnyBins(refSeq.IdToChunks, beginBin + 1, endBin - 1);
                if (hasInternalVariants)
                {
                    return(true);
                }
            }

            // finally we have to check the remaining (edge) bins
            var block = new BgzfBlock();

            refSeq.IdToChunks.TryGetValue(beginBin, out var beginChunks);
            refSeq.IdToChunks.TryGetValue(endBin, out var endChunks);

            return(HasVariantsInBin(refSeq.Chromosome, begin, end, block, beginChunks) ||
                   HasVariantsInBin(refSeq.Chromosome, begin, end, block, endChunks));
        }