Beispiel #1
0
        // ReSharper disable once UnusedMember.Global
        public static long GetOffset(this Index index, string chromosomeName, int begin)
        {
            var refSeq = index.GetTabixReferenceSequence(chromosomeName);

            if (refSeq == null)
            {
                return(-1);
            }

            // N.B. tabix assumes begin is 0-based and end is 1-based
            int end = begin;

            begin = AdjustBegin(begin);

            if (begin == 0)
            {
                return(refSeq.LinearFileOffsets.FirstNonZeroValue());
            }

            ulong minOffset = GetMinOffset(refSeq, begin);
            ulong maxOffset = GetMaxOffset(refSeq, end);

            int bin = BinUtilities.ConvertPositionToBin(begin);

            if (refSeq.IdToChunks.TryGetValue(bin, out Interval[] chunks))
Beispiel #2
0
        public static long GetOffset(this Index index, string chromosomeName, int begin)
        {
            var refSeq = index.GetTabixReferenceSequence(chromosomeName);

            if (refSeq == null)
            {
                return(-1);
            }

            // N.B. tabix assumes begin is 0-based and end is 1-based
            int end = begin;

            begin = AdjustBegin(begin);

            if (begin == 0)
            {
                return(refSeq.LinearFileOffsets.FirstNonZeroValue());
            }

            ulong minOffset = GetMinOffset(refSeq, begin);
            ulong maxOffset = GetMaxOffset(refSeq, end);

            int bin = BinUtilities.ConvertPositionToBin(begin);

            if (refSeq.IdToChunks.TryGetValue(bin, out var chunks))
            {
                return(GetMinOverlapOffset(chunks, minOffset, maxOffset));
            }

            int linearIndex = begin >> Constants.MinShift;

            if (linearIndex >= refSeq.LinearFileOffsets.Length)
            {
                return(-1);
            }

            return((long)refSeq.LinearFileOffsets[linearIndex]);
        }
Beispiel #3
0
        public void ConvertPositionToBin_Nominal()
        {
            int observedResults = BinUtilities.ConvertPositionToBin(26699126);

            Assert.Equal(6310, observedResults);
        }