Some questions about eachoverlap in GenomicFeatures

During using the eachoverlap function in GenomicFeatures,I cannot know how to solve this problem.
My problem is :if each interval in “col” contains any interval in “hhh” ,I will output interval "col ".Here is the picture(below). For example col’s 10628-10683 contains 10631 in hhh,I will output the first line in col.Next 10643-10779 in col contains hhh’s 10648 .If col’s interval does not contain any hhh’s interval,we will discard this col’s line.


I typed in this code.and cannot solve it.

eachoverlap(col,hhh,isless)


And I also tried isoverlappiing,unfortunately it was slow.

k=IntervalCollection{String}()
for a in col ,b in hhh
    if isoverlapping(a,b)
        if (a in k)==false
            push!(k,a)
        end
    end
end

So would you please tell me how I can handle this issue?I will be grateful to you.

Hi,

eachoverlap returns you a list that contains pairs of intervals that have overlap, so each pair contains one interval from col and one interval from hhh. Since you only want the intervals from col here, you can take the first value in each pair:

first.(eachoverlap(col, hhh))

This will return a Vector{Interval{String}} i.e. a Vector containing the Intervals from col that have overlap with any in hhh.

If you want this as an IntervalCollection instead, you can instead do:

IntervalCollection{String}(c for (c, h) in eachoverlap(col, hhh))