Samtools sort error with a bam file
1
0
Entering edit mode
6.7 years ago
Vasu ▴ 790

I have raw data fastq.gz files for some samples. Using Hisat2 for aligning reads to genome and used samtools converted sam to bam format. Also used samtools sort for sorting the bam file. For all the samples I used following command:

hisat2 -p 8 --dta --rna-strandness RF --trim3 3 -x genome_snp_tran -1 /A.1.fastq.gz -2 /A.2.fastq.gz | samtools view -Sb - > A.bam
samtools sort -T /tmp/A.sorted -o A.sorted.bam A.bam  



A.1.fastq.gz 8.9G
A.2.fastq.gz 9.7G

For most of the samples this worked. For one sample I got an error at sorting step. I got the A.bam file (40G) but got an error for sorting.

[E::bgzf_flush] hwrite error (wrong size)
[E::bgzf_close] file write error
[bam_sort_core] failed to create temporary file "/tmp/A.sorted.0468.bam": No space left on device

What I have to do now?

RNA-Seq samtools sort bam • 4.3k views
ADD COMMENT
0
Entering edit mode
6.7 years ago

The error you see is quite obvious: there is no disk space left on the device for the intermediate files written while sorting.

Note that you can shorten your command considerably and avoid an intermediate file by piping hisat2 directly into samtools sort:

hisat2 -p 8 --dta --rna-strandness RF --trim3 3 -x genome_snp_tran -1 /A.1.fastq.gz -2 /A.2.fastq.gz | samtools sort -o A.bam -

This probably requires a recent samtools version.

ADD COMMENT
0
Entering edit mode

What I should do now for sorting step?

ADD REPLY
1
Entering edit mode

You'll additionally want to set a temporary directory with the -T option, like -T /some/place/with/space/FileName.

ADD REPLY
1
Entering edit mode

Bioinfo : Add this option to the command @Wouter provided above.

ADD REPLY
1
Entering edit mode

As you can see I added the sorting step to the end of the hisat command.

ADD REPLY
0
Entering edit mode

Thank you very much for the answers !!

ADD REPLY

Login before adding your answer.

Traffic: 2752 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