This is a test version of Biostars. For the public version, visit https://www.biostars.org.
how to use samtools sort correctly?

hi everyone, I have a question: I run the following command in the samtools sorted and failed to created the output file:

$Samtools sort -n $Temp/$i.out/accepted_hits.bam -o $oDirectory/$i.out/accepted_hits_sorted.bam

and the error it's:

[sort_blocks] fail to create file /home/lgts/workspace/rnaseq/Output/KG-1_DM4h-6_6.out/accepted_hits_sorted.bam.0000.bam.

thanks you for your answers

rna-seq samtools

In addition to the question of genomax, can you check your hard disk isn't full and the directory you are writing to does exist?

thank you for reply genomax and Wouterdecoster. I was checking my menory capacity and apparentely that's the problem. when I solve this, I tell them if I solved the problem.

thanks again

That does not sound correct. Memory should have no effect on your ability to write to a specific directory.

3 answers

You are using samtools 0.1.18, which was released almost seven years ago.

If you use any of the last seven released versions of samtools, this error message will explain why it was unable to create this temporary file.

Is the directory /home/lgts/workspace/rnaseq/Output/KG-1_DM4h-6_6.out/ not writable from the account you are running samtools sort from?

hi everybody,

I wanted to comment how finished my history with "samtools sort"

my mistake was, the syntax of the command

I used this command: $Samtools sort -n $Temp/$i.out/accepted_hits.bam -o $oDirectory/$i.out/accepted_hits_sorted.bam

and the correct command it's

samtools sort -n input.bam output.bam

Thanks to all for the help...

As @John said above (he is the maintainer of samtools so he knows) you are likely using samtools v.0.1.18. Please upgrade ASAP. That is a version that is 7 years old at this time and should no longer be used (unless required as a dependency by some other tool).

It's not merely “likely using” — that error message with that exact wording does not exist past 0.1.18. And, for the record, since leaving Sanger I continue to have some interest in samtools but am not “the maintainer” of samtools.

If ancient samtools is still required by particular other tools, IMHO those other tools should be named, shamed, and fixed.

Thanks for clarifying that.

Log in to answer this question.