This is a test version of Biostars. For the public version, visit https://www.biostars.org.
create index bam without having sam file

hi everyone I need to create bam index for variant analysis.but I havenot sam files only bam files avaible.how I can create it? I tried

for i in $(ls $RNA_HOME/alignments/hisat2/*.bam  | tr -s '/.' ' ' | awk '{print $(NF-1)}') 
do
  samtools sort $RNA_HOME/alignments/hisat2/$i.bam > $i.bam
  samtools index $i.bam
  echo indexing of $i finished
done

and I get an error

 [bam_sort_core] merging from 9 files and 1 in-memory blocks...

Thank you for any little help

bam

1 answer

What you see is not an error but just a message telling you that many temporary files have been merged into one, that happens when there is less memory available than the sorting needs so it starts writing tmp files to disk and then merges them. No worries about that. Use ls to see if the bai files are present. In fact only bam files can be indexed with samtools, not sam files. It should be fine.

oh thank you. this answer gave me such relief .

Log in to answer this question.