Entering edit mode
8.0 years ago
a.rex
▴
350
Is there an efficient way of joining two files in the following way - i.e. using BedTools?
For example, FILE 1:
scaffold1 0 206 transcript_loc.00001 exon
scaffold1 262 749 transcript_loc.00001 exon
scaffold1 1391 1549 transcript_loc.00001 exon
FILE2:
scaffold1 517 540 Simple_repeat
scaffold1 1063 1162 LTR/Gypsy
scaffold1 1400 1498 LTR
Resultant file:
scaffold1 0 206 transcript_loc.00001 exon
scaffold1 262 749 transcript_loc.00001 exon 517 540 Simple_repeat
scaffold1 1391 1549 transcript_loc.00001 exon 1400 1498 LTR
In this way, wherever the two files intersect, the intersection is appended to a new column on the first file. The non-intersect is discarded.
Many thanks.
This can be done with
intersectBed
option from BedTools. Checkwa
,wb
,wo
options. Before using bedtools change your file formats to actual BED format.