Пример #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);
        }
Пример #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));
        }
Пример #3
0
        private bool HasVariantsInBin(IChromosome chromosome, int begin, int end, BgzfBlock block, Interval[] intervals)
        {
            (long minVirtualOffset, long maxVirtualOffset) = SearchUtilities.GetMinMaxVirtualFileOffset(intervals);

            long minOffset = VirtualPosition.From(minVirtualOffset).FileOffset;
            long maxOffset = VirtualPosition.From(maxVirtualOffset).FileOffset;

            return(BgzfBlockVcfReader.FindVariantsInBlocks(_vcfStream, minOffset, maxOffset, block, chromosome, begin, end));
        }