closestBed output bug with "-d"

48 views
Skip to first unread message

Assaf Gordon

unread,
Feb 23, 2012, 11:57:11 AM2/23/12
to bedtools...@googlegroups.com, Emily Hodges
Hi Aaron,

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

Aaron Quinlan

unread,
Feb 23, 2012, 12:33:18 PM2/23/12
to bedtools...@googlegroups.com, Emily Hodges

Hi Gordon and Emily,

I'm traveling, but will try to have a look this PM.

Aaron

Assaf Gordon

unread,
Feb 23, 2012, 1:28:06 PM2/23/12
to bedtools...@googlegroups.com, Emily Hodges
Good news!

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
>

Aaron Quinlan

unread,
Feb 23, 2012, 1:40:58 PM2/23/12
to bedtools...@googlegroups.com, Emily Hodges
Thanks for the follow-up and improvement to the Makefile, Gordon. I've been doing this manually in the past - this is much better.

Cheers,
Aaron

Reply all
Reply to author
Forward
0 new messages