Bwa Sampe Segmentation Fault
5
2
Entering edit mode
12.5 years ago
a11msp ▴ 120

Hi everyone,

I'm running bwa in the sampe mode and, after successfully processing >10M reads it fails with a segmentation fault (as follows) on what appears like a set of poorly-alignable reads. Any suggestions on what can be done to overcome this problem would be much appreciated. Many thanks!

#chunk processed ok
[bwa_read_seq] 2.8% bases are trimmed.
[bwa_sai2sam_pe_core] convert to sequence coordinate... 
[infer_isize] (25, 50, 75) percentile: (492, 529, 561)
[infer_isize] low and high boundaries: 354 and 699 for estimating avg and std
[infer_isize] inferred external isize from 55618 pairs: 523.901 +/- 55.549
[infer_isize] skewness: -0.798; kurtosis: 0.914; ap_prior: 2.38e-04
[infer_isize] inferred maximum insert size: 897 (6.71 sigma)
[bwa_sai2sam_pe_core] time elapses: 9.46 sec
[bwa_sai2sam_pe_core] changing coordinates of 9766 alignments.
[bwa_sai2sam_pe_core] align unmapped mate...
[bwa_paired_sw] 76039 out of 91346 Q17 singletons are mated.
[bwa_paired_sw] 5151 out of 16392 Q17 discordant pairs are fixed.
[bwa_sai2sam_pe_core] time elapses: 52.09 sec
[bwa_sai2sam_pe_core] refine gapped alignments... 4.60 sec
[bwa_sai2sam_pe_core] print alignments... 1.93 sec
[bwa_sai2sam_pe_core] 11010048 sequences have been processed.

# failed chunk
[bwa_read_seq] 3.1% bases are trimmed.
[bwa_sai2sam_pe_core] convert to sequence coordinate... 
[infer_isize] fail to infer insert size: too few good pairs
[bwa_sai2sam_pe_core] time elapses: 11.07 sec
[bwa_sai2sam_pe_core] changing coordinates of 0 alignments.
[bwa_sai2sam_pe_core] align unmapped mate...
[bwa_paired_sw] 0 out of 0 Q17 singletons are mated.
[bwa_paired_sw] 68090 out of 140740 Q17 discordant pairs are fixed.
[bwa_sai2sam_pe_core] time elapses: 63.65 sec
[bwa_sai2sam_pe_core] refine gapped alignments... 
/spool/1339511835.1833481: line 8:  9921 Segmentation fault      (core dumped) 
../../bwa-0.6.1/bwa sampe -a 2000 ../myGenome.fa myReads.PE500.4.1.sai myReads.PE500.4.2.sai myReads.PE500.4.1.fq myReads.PE500.4.2.fq > myReads.PE500.4.bwape.sam
bwa paired-end • 11k views
ADD COMMENT
2
Entering edit mode

I had some seg fault problems with sampe awhile ago and after trying 101 different things, I eventually gave up and used bowtie2. So I'm curious to see what happens here.

That said, I would suggest mentioning what version of bwa you're using (or have tried) and hopefully post part of your failing data file somewhere if you want others to take a look.

ADD REPLY
1
Entering edit mode

Haha. We both posted the same time with the same answer.

ADD REPLY
2
Entering edit mode

I posted this question to the bwa mailing list and received the following patch from Mark Kelly that may fix this bug:

diff -crN bwa-0.6.1-orig/bwase.c bwa-0.6.1-fix/bwase.c
*** bwa-0.6.1-orig/bwase.c      Mon Nov 28 08:55:02 2011
--- bwa-0.6.1-fix/bwase.c       Tue Jun 12 13:05:17 2012
***************
*** 245 - 251 ****
                       }
               }
       } else { // no gaps
!               for (z = u = 0; z < (bwtint_t)len; ++z) {
                       c = pacseq[(x+z)>>2] >> ((~(x+z)&3)<<1) & 3;
                       if (c > 3 || seq[y+z] > 3 || c != seq[y+z]) {
                               ksprintf(str, "%d", u);
*** 245 - 251 ***
                       }
               }
       } else { // no gaps
!               for (z = u = 0; z < (bwtint_t)len && x+z < l_pac; ++z) {
                       c = pacseq[(x+z)>>2] >> ((~(x+z)&3)<<1) & 3;
                       if (c > 3 || seq[y+z] > 3 || c != seq[y+z]) {
                               ksprintf(str, "%d", u);

Am re-running with the patched version now and if it works, will post it as an update to the question and close it.

ADD REPLY
1
Entering edit mode

Update: With this patch, the run lasted a little longer but eventually died in a very similar setting. Perhaps the patch is in the right place, but is not fully adequate...

ADD REPLY
2
Entering edit mode

I had this exact problem and tried all the usual suspects. Sadly I couldn't figure it out and ended up using bowtie 2.

ADD REPLY
0
Entering edit mode

Same here:

bwa sampe -s -A -r "@RG\tID:id\tLB:foo\tSM:id\tPL:ILLUMINA" hg19 1.sai 2.sai 1.fq 2.fq ... [bwasai2sampe_core] convert to sequence coordinate... Segmentation fault (core dumped)

This happens within 2 seconds of starting the program. For me, this result is reproducible:

  • Across bwa-0.5.9, bwa-0.6.1 and bwa-0.6.2
  • Across 50 different pairs of .sai files
  • With a variety of optional parameters: with or without -s and -A,
    different @RG string lengths, outputting to .sam file or piping to samtools.
ADD REPLY
0
Entering edit mode

I had this exact same seg fault 2 seconds after running. The sai file was produced on a cluster using bwa 0.7, and I was running sampe on another server with bwa 0.6. When I installed and ran bwa sampe using bwa 0.7, it worked perfectly. Might be worth trying the new version. -- Hope that helps people with this same issue.

ADD REPLY
1
Entering edit mode
11.9 years ago
evelyne.c88 ▴ 10

This exact error can also occur when wrong reference files are used (so when the chromosome id's in the reference index do not match those in the .sai)

ADD COMMENT
0
Entering edit mode

I was having the same problem and after I rebuilt the BWA indexes everything worked fine

ADD REPLY
0
Entering edit mode
12.5 years ago

Multiple users reported problems with bwa in similar circumstances. See comments to the question.

The main purpose of this answer is to label this question answered so that more people look at it and the excellent comments to the question

ADD COMMENT
0
Entering edit mode
12.4 years ago

We were getting a segmentation fault with sampe in version 0.5.9 because n_occ and rest were overflowing in bwase.c and becoming negative, so I changed from line 46:

if (n_multi) {
    int k, rest, n_occ, z = 0;
    for (k = n_occ = 0; k < n_aln; ++k) {
        const bwt_aln1_t *q = aln + k;
        n_occ += q->l - q->k + 1;
    }

to:

if (n_multi) {
    unsigned int k, rest, n_occ, z = 0;
    for (k = n_occ = 0; k < n_aln; ++k) {
        const bwt_aln1_t *q = aln + k;
        n_occ += q->l - q->k + 1;
    }

as q->l and q-> are defined as uint_32 if you look in the appropriate header. It worked after the above change. I don't know if this is related to your problem.

ADD COMMENT
0
Entering edit mode
11.4 years ago
mghandi • 0

I had similar problem with bwa version 0.7.4. but then I switched to bwa ver 0.6.2 and it worked fine.

ADD COMMENT
0
Entering edit mode
9.7 years ago
deepue ▴ 160

I had a sample run paired-end sequenced in two lanes, sample data of first lane has run successfully but the second lane data is having "Segmentation fault" error. If this is due to version issue or memory, the first one should have failed. What might be the issue ? Could someone please help me.

Thanks

ADD COMMENT

Login before adding your answer.

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