This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fail to generate .bai index with samtools

I am using

samtools index -b A.bam

to generate .bai indx file but I always get A.csi format index file.

Anything wrong with it?

assembly rna-seq alignment

What's your samtools version? I went through all of samtools versions, none of them produce csi files unless asked for with the -c parameter. Maybe there's an alias interfering with your command?

Also, even if you got the csi file, it should be A.bam.csi, not A.csi. Are you sure the csi file is being produced by the samtools command you're running?

yes, it's A.bam.csi, Here is the version Program: samtools (Tools for alignments in the SAM format) Version: 1.7 (using htslib 1.7-2) Here is the exact command I used

samtools index -b bai_R1_trimmed20-3.bam -m 18

I got bai_R1_trimmed20-3.bam.csi

Are you using a very large genome for these alignments? What happens if you don't use -m 18? Setting that may be leading to .csi indexes.

really? I use that cause I have large dataset to process. Will try without.

1 answer

If you meant to use more threads (cores) then that option is -@ INT Sets the number of threads [none].

e.g. samtools index -@ 12 -b bai_R1_trimmed20-3.bam

Nice, it works. indeed -m has an effect on the output format. don't know why though;). Thanks.

By using -m you indirectly instructed samtools to create .csi indexes, since that option only applies to those.

Hello bing.bai ,

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

Log in to answer this question.