Question: Samtools sort error with a bam file
0
gravatar for Vasu
23 months ago by
Vasu420
Vasu420 wrote:

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?

sort rna-seq samtools bam • 1.4k views
ADD COMMENTlink modified 23 months ago by Devon Ryan94k • written 23 months ago by Vasu420
0
gravatar for WouterDeCoster
23 months ago by
Belgium
WouterDeCoster43k wrote:

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 COMMENTlink modified 23 months ago • written 23 months ago by WouterDeCoster43k

What I should do now for sorting step?

ADD REPLYlink written 23 months ago by Vasu420
1

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

ADD REPLYlink written 23 months ago by Devon Ryan94k
1

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

ADD REPLYlink written 23 months ago by genomax78k
1

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

ADD REPLYlink written 23 months ago by WouterDeCoster43k

Thank you very much for the answers !!

ADD REPLYlink written 23 months ago by Vasu420
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1758 users visited in the last hour