This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Get completely overlapping features

Hi all,

One simple question, I want to retrieve all features in A that overlap completely (not partially) in B.

Is there anyway to do this using bedtools intersect? I've tried using the following command:

bedtools intersect -a file.gff3 -b file.bed -wa > output

But checking the output, I get this line and actually one base is outside my desired region so I would like discard it.

file.gff3
SL2.40ch01    ITAG_eugene    gene    65436585    65439158

file.bed
SL2.40ch01    65436585    65442158

output
SL2.40ch01    ITAG_eugene    gene    65436585    65439158

Thanks!

bedtools intersect

1 answer

What version of bedtools are you using?

In bedtools v2.22.0 there are these two options, which combined should give you what you need:

intersectBed -h
...
    -f    Minimum overlap required as a fraction of A.
        - Default is 1E-9 (i.e., 1bp).
        - FLOAT (e.g. 0.50)

    -r    Require that the fraction overlap be reciprocal for A and B.
        - In other words, if -f is 0.90 and -r is used, this requires
          that B overlap 90% of A and A _also_ overlaps 90% of B.

Log in to answer this question.