Question: bwa mem seq and Segmentation fault (core dumped)
0
gravatar for Whoknows
3.3 years ago by
Whoknows740
Tehran,Iran
Whoknows740 wrote:

Hi

I ran bwa mem on a SRA exome file (SRR2968047) but i saw following error :

Segmentation fault (core dumped)

Indexing was done successfully, and my command is :

bwa mem -t 3 -R '@RG\tID:SRR2968047\tSM:ExomeSample1\tPL:Illumina\tPU:Hiseq2500' -M Genome/hg38 Raw/Clean/1.fq.gz Raw/Clean/2.fq.gz | samtools view -Sbh | samtools sort - aln-sorted

other feature of my system:

  • OS: Fedora
  • RAM : 7GB
  • CPU: 4 core

How can I fix this problem??

bwa exome genome • 3.6k views
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by Whoknows740
1

I ran your command. It works fine to me. It seems you have Memory problem. May be RAM or CPU. Here is my suggestion to come to a solution:

1- Extract around 20000 reads: head -n 20000 SRR.fastq > SRR_new.fastq

2- Run bwa again with option "-t 2" not -t 3. And exclude this part of the pipeline for now "samtools view -Sbh | samtools sort - aln-sorted".

Give us a feedback then

Hope it helps.

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by fernardo 130
1

Or even -t 1, I believe bwa uses 5 point something Gb of memory for aligning against the human genome.

ADD REPLYlink written 3.3 years ago by Zaag720
0
gravatar for Sukhdeep Singh
3.3 years ago by
Sukhdeep Singh9.8k
Netherlands
Sukhdeep Singh9.8k wrote:

Segmentation fault (segfault) is a very generic error, there can be several reasons for this. Best is to check the log, if you generate any or switch on the verbose functionality. Also, check problems like do you have enough disk space, tmpdir is empty etc. It could also be related to the file permissions and the location you are trying to write the output to, is it accessible?

Also, I just looked at this post here, Bwa mem is exiting with segmentation fault for large contigs (> 0.4Mbp), as suggest by Heng, use the updated version of bwa.

ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by Sukhdeep Singh9.8k

please see the error log:

bam_header_read] EOF marker is absent. The input is probably truncated. [bam_header_read] invalid BAM binary header (this is not a BAM file). [M::bwa_idx_load_from_disk] read 0 ALT contigs [M::process] read 412708 sequences (40000092 bp)... [M::process] read 412590 sequences (40000195 bp)... [M::mem_pestat] # candidate unique pairs for (FF, FR, RF, RR): (1, 158858, 7, 5) [M::mem_pestat] skip orientation FF as there are not enough pairs [M::mem_pestat] analyzing insert size distribution for orientation FR... [M::mem_pestat] (25, 50, 75) percentile: (87, 116, 161) [M::mem_pestat] low and high boundaries for computing mean and std.dev: (1, 309) [M::mem_pestat] mean and std.dev: (128.09, 53.87) [M::mem_pestat] low and high boundaries for proper pairs: (1, 383) [M::mem_pestat] skip orientation RF as there are not enough pairs [M::mem_pestat] skip orientation RR as there are not enough pairs [M::mem_process_seqs] Processed 412708 reads in 208.661 CPU sec, 685.940 real sec Segmentation fault (core dumped)

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Whoknows740
1

As Sukhdeep said there are several possible reasons. From my experience these are things you can try to diagnose and solve:

Is your machine 32 or 64 bit? We've tried to run bwa mem on 32 bit and we also got a segmentation fault so it's best to run on 64 bit.

Another very possible reason is that there isn't sufficient memory to run bwa mem. It has pretty high memory requirements and if you are running some heavy processes at the same time it could lead to that error.

I see that you are piping the bwa mem result to samtools, have you tried seperating these commands? This also has to do with memory.

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by alons270
0
gravatar for genomax
3.3 years ago by
genomax69k
United States
genomax69k wrote:

Heng Li has said that bwa requires 5.5G RAM with one thread. Splitting the alignment/samtools into separate operations (as suggested by @alons may allow this to work considering the 7GB RAM (odd number but hopefully correct) available per original post.

ADD COMMENTlink written 3.3 years ago by genomax69k
0
gravatar for Whoknows
3.3 years ago by
Whoknows740
Tehran,Iran
Whoknows740 wrote:

Thanks all of you and fernardo for helping me.

After splitting 20K reads from fastq files and updaing zlib for bwa it showed same error by using pipe command, take a look

[M::worker2@2] performed mate-SW for 43682 reads [M::worker2@3] performed mate-SW for 44128 reads Segmentation fault (core dumped)

but when I ran commands separately (without pipe) it works fine for 20K reads at last!! And sorted-bam file size is ~12 MB.

I'm also curious about below information running samtools on sam file.

  • [samopen] SAM header is present: 24 sequences.
    • [bam_header_read] EOF marker is absent. The input is probably truncated.

why it has only 24 sequences?
And, What EOF marker is absent means??

ADD COMMENTlink written 3.3 years ago by Whoknows740

How many scaffolds in your reference?

ADD REPLYlink written 3.3 years ago by 5heikki8.4k

I don't know exactly, I used UCSC-hg38 reference for my data.

ADD REPLYlink written 3.3 years ago by Whoknows740

That's probably 22 autosomes + x and y makes 24 sequences in the header

EOF marker is absent means that your file has no proper end and probably it is malformed in some way. How did you go from sam to sorted bam?

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Zaag720

I used this code:

bwa mem -t 4 -R '@RG\tID:SRR2968047\tSM:ExomeSample1\tPL:Illumina\tPU:Hiseq2500' -M Genome/hg38 Raw/Clean/1.fq.gz Raw/Clean/2.fq.gz  > out.sam

samtools view -Sbh out.sam | samtools sort - aln-sorted
ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Whoknows740

and if you try it like this:

samtools view -Sb out.sam -o out.bam
samtools sort out.bam aln-sorted

should give you a aln.sorted.bam that should be ok

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by Zaag720
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: 1669 users visited in the last hour