This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bedops --element-of misses elements

Bedops --element-of misses an element in a test input file that I think it should be reporting and I'm not sure why. Here is the command I run:

bedops --element-of 1 A_file.bed B_file.bed

A_file:

chr17 14 19 ENST20 . +

chr17 20 26 ENST21 . +

chr17 24 27 ENST22 . -

chr17 28 35 ENST23 . +

chr17 32 37 ENST24 . +

B_file:

chr17 14 17 ENST20 . +

chr17 16 18 ENST21 . +

chr17 27 30 ENST22 . -

chr17 29 30 ENST23 . +

chr17 31 34 ENST24 . -

chr17 32 38 ENST24 . +

This is the output I am expecting:

chr17 14 19 ENST20 . +

chr17 28 35 ENST23 . +

chr17 32 37 ENST24 . +

This is the output that I'm getting:

chr17 14 19 ENST20 . +

chr17 28 35 ENST23 . +

In other terms, I am not recovering the last element in A_file, even though it overlaps the last two elements in B_file. I would be really grateful for any ideas as to what is going on!

bedops --element-of

1 answer

Does the last line end in a newline character? Use cat -e file.bed to check. If it lacks a newline it might get ignored.

Good thinking! yep, file A lacked a newline. Strangely enough, bedtools doesn't seem to care either way, it's only an issue with bedops. Thanks a lot for your help!

Log in to answer this question.