Can the input file name be the same as the output file in `samtools sort`?
0
0
Entering edit mode
2.2 years ago
Dan ▴ 180

Hi

I am confusing what is happening if the input file name is the same as the output file in samtools sort?

samtools sort -n file1.bam -o file1.bam

This command can run successfully, but is it correct?

Thanks a lot

Best
Dan

Samtools • 859 views
ADD COMMENT
2
Entering edit mode

This command can run successfully

may be, because the output is written after all the reads have been read and sorted.

but is it correct?

no. It's not the unix way, it looks weird, and there is no advantage compared to

samtools sort -n file1.bam -o file2.bam
mv file2.bam file1.bam
ADD REPLY
4
Entering edit mode

It is also prone to disaster. If the job gets killed while the new file is being written then the data are lost and you have to repeat alignment. It’s bad practice don’t get used doing that.

ADD REPLY

Login before adding your answer.

Traffic: 1402 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6