We've found a strange bug with the output of "closest bed" in certain cases - an extraneous "\r" is printed, messing up the output.
Here's an example:
==============
$ cat a.bed
chr1 1088346 1096346 foo
$ cat b.bed
chr1 13866549 13867194 bar
# simple usage, no problem:
$ bedtools closest -a a.bed -b b.bed
chr1 1088346 1096346 foo chr1 13866549 13867194 bar
# adding "-d", output is messed-up (look at second/third columns):
$ bedtools closest -a a.bed -b b.bed -d
chr1 127702031096346 foo chr1 13866549 13867194 bar
# hex dump of the output shows an extra "\r" written after the bed intervals are printed
# (after "bar" on the fourth line), then a tab, then the distance, which causes the distance to overwrite the start/end columns.
$ bedtools closest -a a.bed -b b.bed -d | od -c
0000000 c h r 1 \t 1 0 8 8 3 4 6 \t 1 0 9
0000020 6 3 4 6 \t f o o \t c h r 1 \t 1 3
0000040 8 6 6 5 4 9 \t 1 3 8 6 7 1 9 4 \t
0000060 b a r \r \t 1 2 7 7 0 2 0 3 \n
0000076
==============
This happens with the latest git version (39665f0).
I'm trying to find the offending code in closetBed.cpp, but perhaps you can think of it quicker...
Thanks to Emily (CC'd) for reporting this bug.
-gordon
Hi Gordon and Emily,
I'm traveling, but will try to have a look this PM.
Aaron
Not a bug, just a human operator error :)
Darn windows-style line endings, I should have checked it first thing.
There's a silver lining, though -
To debug bedtools with GDB I needed some extra CXXFLAGS, I've added them as an option to the Makefile.
(Pull request is in git-hub).
So to build a debuggable binary, run "make clean && make DEBUG=1" - this will not only include debug information, but will also prevent inline'd function from being inline'd, and allow to debug them.
-gordon
Aaron Quinlan wrote, On 02/23/2012 12:33 PM:
> Hi Gordon and Emily,
>
> I'm traveling, but will try to have a look this PM.
>
> Aaron
>
Cheers,
Aaron