#18 BWA 0.4.6 aborts when reads align off seq end


Hi, I frequently get the following error when using BWA 0.4.6 to do alignments:

[bns_coor_pac2real] bug! Coordinate is longer than sequence (4294967295>=98936). Abort!

I've tracked down some cases that seem to trigger this, and it seems to occur when a read is mapped by BWA 'aln' (slightly) off of the end of a reference sequence.
A subsequent call to BWA 'samse' will then produce this error, presumably because the read has a negative (wraparound) coordinate relative to the beginning of the reference sequence. Some kind of sign/underflow error related to this case.

To replicate: Choose some relatively short sequence (1000-2000nt will do.) Generate some simulated reads from this sequence (e.g. use Maq 'simulate', I've been working with 35-50nt reads). Create enough reads that all start points in the ref sequence will be covered with good quality reads.

Now, trim the front end off of this ref sequence (say 100nt) and build a BWA index (-a is) with this new trimmed ref sequence. Use BWA to Align your reads from above to the index. (aln -c -t 8 -n 4) Now run bwa samse. You should eventually get the error I get above.
I have been doing alignments in color space, and I run samse with the -n INT option, and I have not tested for this error outside of those settings, so you *may* need to do the same to replicate.

The error seems to occur when a read is placed by bwa aln like this: (R= read, S= ref sequence)


The n bases of the read dangling off the front end of the reference sequence cause the samse to abort.

Thanks for any help. Other than this, BWA is turning out to be a very useful tool, so I hope this is easy to fix!

Cheers, Vaughn (vsi at u.washington.edu)


  • Nobody/Anonymous

    The spaces didn't show up in my little diagram above. Try this:


  • Nobody/Anonymous

    Two new pieces of information:

    1) This is not dependent on colorspace alignments. Same error occurs when using nt space only.
    2) When bwa samse is run without the -n parameter, this case manifests as a segmentation fault instead of the error message described in the parent.

  • Nobody/Anonymous

    Hi, this problem indeed appears to be due to an improper conversion from signed to unsigned 32 bit integer position values in several locations in bwa. The following change causes the errors to cease and BWA *appears* to work properly, although I have not fully validated its correctness after this change has been applied.

    In bwt.h, change the type of bwtint_t from uint32_t to int32_t. That is, from unsigned to signed.

    I'm sure this potentially changes many things within BWA. The specific problem I've identified relates to the unsigned values of the "pos" member of the structure type "bwa_seq_t" defined in file bwtaln.h. There are also several function parms and local variables in file bwase.c (e.g. function: refined_gapped_core, parm 6 "pos"; function print_aln_simple, local var "pos") that are unsigned and contribute to this problem. As a first attempt to isolate this problem with read positions, I changed the type of bwtint_t as descirbed above and it seems to work fine (for my dataset) although more localized changes to the position specific variables, parms, struct members as described (plus others, I'm sure) may be more desirable.

    Thanks! I hope that this helps to quickly get this issue fixed in a forthcoming version of BWA. Vaughn
    vsi at u.washington.edu

  • lh3

    lh3 - 2009-08-20
    • status: open --> closed
  • lh3

    lh3 - 2009-08-20

    This is a known bug and I believe it has been fixed in the latest release and so I am going to close this ticket. Thanks anyway.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks