The subsequent step is failing with error message sorted.bam is not coordinate sorted. To my surprise, though the step has completed successfully, it created an empty file.
Could you please help me understand what might be the reason?
Edit:
This has been posted in a new thread not to hijack this unnoticed one.
If I understand your question correctly, you can do it using samtools sort with -O command:
samtools sort -O sam -T sample.sort -o sample.sort.sam sample.sam
where: -O is to specify output format; -T is to specify prefix, and I think it's needed because samtools sort create a few temporary files with this prefix; -o is your output file name. sample.sam is the original input.
Doing so, you basically sort sam file, and directly output sam file in one command.
Did you by chance do sort -O sam -T sample.sort -o sample.sort.sam sample.sam instead of samtools sort -O sam -T sample.sort -o sample.sort.sam sample.sam? Becuase the error you get doesn't look like a samtools error.
-O FORMAT
Write the final output as sam, bam, or cram.
By default, samtools tries to select a format based on the -o filename extension; if output is to standard output or no format can be deduced, bam is selected.
-T PREFIX
Write temporary files to PREFIX.nnnn.bam, or if the specified PREFIX is an existing directory, to PREFIX/samtools.mmm.mmm.tmp.nnnn.bam, where mmm is unique to this invocation of the sort command.
Samtools has a build in sort command. If you're interested in knowing more about any command or program usually > x.sh --help or > x.sh -h works. For some bash command typing 'man' before a command opens the manual
2018: with a recent samtools , the syntax has changed and you don't need to use 'samtools view'
Hi,
I have tried to use the below pipeline based on the above suggestion.
The subsequent step is failing with error message
sorted.bam is not coordinate sorted.
To my surprise, though the step has completed successfully, it created an empty file.Could you please help me understand what might be the reason?
Edit:
This has been posted in a new thread not to hijack this unnoticed one.
samtools error when using pipeline view/sort/index