# Some questions about eachoverlap in GenomicFeatures

**URL:** https://discourse.julialang.org/t/some-questions-about-eachoverlap-in-genomicfeatures/85975
**Category:** General Usage
**Created:** [August 19, 2022, 7:03am UTC](https://discourse.julialang.org/t/some-questions-about-eachoverlap-in-genomicfeatures/85975 "2022-08-19T07:03:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![zhangchunyong](https://avatars.discourse-cdn.com/v4/letter/z/d9b06d/32.png) [@zhangchunyong](https://discourse.julialang.org/u/zhangchunyong)
#### Post date: [August 19, 2022, 7:03am UTC](https://discourse.julialang.org/t/some-questions-about-eachoverlap-in-genomicfeatures/85975/1 "2022-08-19T07:03:23Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/c/eca15711883798628f41746f4a0e098629532901.png)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/c/ec47e0d47caafa7e70fe71b13ad16ee71d28a4c3.png)  
I typed in this code.and cannot solve it.

```julia
eachoverlap(col,hhh,isless)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/8/e8ea01b183ebd9211e80f0f3e8e4cb50fa3a8d6f.png)  
And I also tried isoverlappiing,unfortunately it was slow.

```julia
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.

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [August 30, 2022, 11:31am UTC](https://discourse.julialang.org/t/some-questions-about-eachoverlap-in-genomicfeatures/85975/2 "2022-08-30T11:31:55Z")

</div>

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:

```julia
first.(eachoverlap(col, hhh))

```

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

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

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

```
