Question: Samtools sort error with a bam file
0
gravatar for Vasu
13 months ago by
Vasu320
Vasu320 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 • 882 views
ADD COMMENTlink modified 13 months ago by Devon Ryan89k • written 13 months ago by Vasu320
0
gravatar for WouterDeCoster
13 months ago by
Belgium
WouterDeCoster38k 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 13 months ago • written 13 months ago by WouterDeCoster38k

What I should do now for sorting step?

ADD REPLYlink written 13 months ago by Vasu320
1

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

ADD REPLYlink written 13 months ago by Devon Ryan89k
1

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

ADD REPLYlink written 13 months ago by genomax65k
1

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

ADD REPLYlink written 13 months ago by WouterDeCoster38k

Thank you very much for the answers !!

ADD REPLYlink written 13 months ago by Vasu320
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: 1978 users visited in the last hour