Hi all,
I have a question as follows: description of sam/bam/cram file format says that there is a limit to chromosome size in bam file. Above this limit you can't create an index of bam file in bai file format. This limit is 2^29-1, which is circa 500 M.b.p. If at least one chromosome in reference sequence is longer than this limit, indexing fails. I've just tried it out:
$ samtools index file_sort.bam
it did fail:
[E::hts_idx_check_range] Region 536962398..536962445 cannot be stored in a bai index. Try using a csi index with min_shift = 14, n_lvls >= 6
[E::sam_index] Read 'NB552414:80:H3WTKBGXK:3:21607:22796:5232' with ref_name='2H', ref_length=665585731, flags=16, pos=536962399 cannot be indexed
samtools index: failed to create index for "file_sort.bam": Numerical result out of range
However, never have i encountered any mention of this problem before. It does not occur often - the limit is actually rather high, all human chromosomes, for example, are smaller than this. But for wheat of barley, some chromosomes are actually larger than this limit, thus preventing users from creating indexes in bai format. There is csi format that does not have this size limitation, but it is not as widely used, and vcftools for example does not work with it.
So, am i just being paranoid, or can this limitation actually prevent user from working on certain genomes as it is? And if it does, how can one overcome it? Split the chromosomes into smaller chunks, of some 300 M.b.p. for example
Thanks for the help in advance,
Nick Shmakov, jr researcher, ICG SB RAS
I have a question as follows: description of sam/bam/cram file format says that there is a limit to chromosome size in bam file. Above this limit you can't create an index of bam file in bai file format. This limit is 2^29-1, which is circa 500 M.b.p. If at least one chromosome in reference sequence is longer than this limit, indexing fails. I've just tried it out:
$ samtools index file_sort.bam
it did fail:
[E::hts_idx_check_range] Region 536962398..536962445 cannot be stored in a bai index. Try using a csi index with min_shift = 14, n_lvls >= 6
[E::sam_index] Read 'NB552414:80:H3WTKBGXK:3:21607:22796:5232' with ref_name='2H', ref_length=665585731, flags=16, pos=536962399 cannot be indexed
samtools index: failed to create index for "file_sort.bam": Numerical result out of range
However, never have i encountered any mention of this problem before. It does not occur often - the limit is actually rather high, all human chromosomes, for example, are smaller than this. But for wheat of barley, some chromosomes are actually larger than this limit, thus preventing users from creating indexes in bai format. There is csi format that does not have this size limitation, but it is not as widely used, and vcftools for example does not work with it.
So, am i just being paranoid, or can this limitation actually prevent user from working on certain genomes as it is? And if it does, how can one overcome it? Split the chromosomes into smaller chunks, of some 300 M.b.p. for example
Thanks for the help in advance,
Nick Shmakov, jr researcher, ICG SB RAS