Hello
I was wondering if anybody could explain the following:
Samtools 1.5 on a SGE setup (modules available are Samtools 0.1.19, 1.2 or 1.5), Calling Samtools from within a shell script.
If I run this sort command:
samtools sort -n contig_XXX_mapped.latest.all.bam -o contig_XXX_mapped.sorted.bam
Then I get a bam file contig_XXX_mapped.sorted.bam in the relevant folder
If I then run:
samtools index contig_XXX_mapped.sorted.bam
We get the error: samtools index: failed to create index for "contig_XXX_mapped.sorted.bam": No such file or directory - as stated that file does exist.
Repeating the sort command without '-n' works just fine - an output file of the same name is created and is indexed.
I cannot find an explanation for this behaviour and I was wondering if anybody could explain it to me?
Many thanks
I tried to reproduce your problem with v1.5, but I didn't get the error what you are having, what I am getting is genuine issue, because I have sorted it on the basis of name. Therefore I think samtools is not able to access your sorted file due to permission. As you are in a cluster environment, just make sure samtools is able to access your input file.
Hi - thanks for the reply, Bit of digging further How to specify the sort based on name in samtools sort? - looks like samtools reports file not found when, in fact, it just cannot index a name sorted file as described below by ATpoint.
But following solution doesn't give the answer of your question. Because I am also getting same error when sorting by name as described in"How to specify the sort based on name in samtools sort? " . But your error is totally different then what is expected. I am still curious why you are getting that error.
It has nothing to do with
samtools
:This is most likely due to the wrapper script that is causing this behaviour, somewhere parsing a wrong file name or something similar.