I want to instead of use the -wa option or -wb option in bedtools intersect, i want the union of all regions which have some intersection.
So if my input is like so (first row bed 1 second row bed 2):
ccccc ccccc cc ccccccccc
cccc ccccccccccccccccccc
then I want the output to be:
ccccccc ccccccccccccccccccc
Is there an operation like this?
I can do bedtools intersect -wa and then -wb on the same input and now I have to files only of regions that contain an intersection, and then take their union, but i was wondering if there was something already implemented.
It's as you say just a pipe of two commands, I do not see the downside of that:
bedtools intersect -a first.bed -b second.bed -wa -wb | bedtools merge -i -See answer.
ah ok. I did not know you could do -wa -wb. Thanks
requires some awk, see below
Thank you all