Entering edit mode
19 months ago
MobiusT
▴
20
I have the following script
samtools index dataset01.bam
basename dataset01.bam
f="$(basename -- dataset01.bam)"
sambamba depth base -L genomic.bed dataset01.bam > ./read_depths/"$f.txt"
I run this script with a whole genome dataset and after that is gives the following error.
samtools index: failed to create or write index
dataset001.bam
sambamba-depth: All files must be coordinate-sorted
What can be the reason for this and it takes more than half a day running so any help could save my time.
I use a conda environment and use the following versions
- sambamba=0.6.6=2
- samtools=1.7=1
you first have to find why samtools failed at this point: is the bam sorted on coordinate ? is the directory writeable ? etc....
Does this not answer your question? Your files must be sorted prior to indexing, or doing pretty much any genomic-coordinate based analysis. Samtools should give a clearer error message. It gives more information now, but it's still not crystal clear IMO. This also implies you're using an out-dated version of samtools.
Try looking at the
samtools sort
man page for detailed usage.