Question: Changing n_lvls in htslib hts.c, or, samtools index error "Numerical result out of range"
gravatar for A Soggy Waffle
15 months ago by
A Soggy Waffle0 wrote:

I'm just trying to index a sorted BAM with samtools index but get the error:

[E::hts_idx_push] Region 536892210..536892211 cannot be stored in a csi index with min_shift = 14, n_lvls = 5. Try using min_shift = 14, n_lvls >= 6 
samtools index: failed to create index for "868om_41_070_010.sorted.bam": Numerical result out of range

no .bai nor .cis is made by the command, as is suggested by enter link description here. I think i found where n_lvls is defined in hts.c (lines 1817, 1829, 1847). However I'm not sure I how I should proceed, i.e. what compiler and options should be used to compile hts.c after I change n_lvls.

htslib samtools sequence • 789 views
ADD COMMENTlink modified 14 months ago by Devon Ryan88k • written 15 months ago by A Soggy Waffle0
gravatar for Devon Ryan
14 months ago by
Devon Ryan88k
Freiburg, Germany
Devon Ryan88k wrote:

Instead of changing the number of levels, instead increase the interval size with -m 15. That will give you a maximum position of 1073741824 (for those wondering the maximum position that can be index is given by 1 << min_shift + n_lvls * 3, or simply 1 << min_shift + 15, since n_lvls is hard coded).

Edit: Actually, the default should work if you're using the most recent version of samtools and make sure to specify the -c option. Then what you're seeing should only happen if (A) you specify -m 0 (then the defaults, which are too small, are used) or (B) you have entries in your BAM file beyond the end of the chromosome.

ADD COMMENTlink modified 14 months ago • written 14 months ago by Devon Ryan88k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1756 users visited in the last hour