bamtools icon indicating copy to clipboard operation
bamtools copied to clipboard

wrong reference length reported on big endian archs

Open satta opened this issue 8 years ago • 0 comments

On big-endian platforms, an apparent problem seems to make bamtools' bamReader.GetReferenceData() return a negative int32_t value as a reference sequence length.

I've attached a small example program bamtools_example.tar.gz to test on both platforms with the BAM file generated by the problematic test case in REAPR, and I can confirm that the problem occurs consistently.

amd64:

[satta:/tmp/tmp.Z5tPunaEOw/result] $ g++ -o bamtools_test  ~/bamtools_test.cpp -I /usr/include/bamtools -lbamtools
[satta:/tmp/tmp.Z5tPunaEOw/result] $ samtools view -H 00.in.bam | grep SQ
@SQ	SN:foo	LN:1000111
[satta:/tmp/tmp.Z5tPunaEOw/result] $ ./bamtools_test 00.in.bam
ref: foo, length: 1000111

mips:

(sid_mips-dchroot)satta@minkus:/tmp/tmp.cWdSvSEoaT/result$ g++ -o bamtools_test ~/bamtools_test.cpp -I /usr/include/bamtools -lbamtools
(sid_mips-dchroot)satta@minkus:/tmp/tmp.cWdSvSEoaT/result$ samtools view -H 00.in.bam | grep SQ
@SQ	SN:foo	LN:1000111
(sid_mips-dchroot)satta@minkus:/tmp/tmp.cWdSvSEoaT/result$ ./bamtools_test 00.in.bam
ref: foo, length: -81

Notice how samtools view shows the same length for both archs but the bamtools test program does not.

satta avatar Aug 08 '17 00:08 satta