Skip to content

Commit

Permalink
Correct non-overlapping query
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranOMara committed May 21, 2020
1 parent a63ab3c commit 0091cb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/intervalcollection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,13 @@ end
# Overlaps
# --------

function eachoverlap(a::IntervalCollection{T}, b::Interval; filter::F = true_cmp) where {F,T}
if haskey(a.trees, b.seqname)
return intersect(a.trees[b.seqname], b)
function eachoverlap(a::IntervalCollection{T}, query::Interval; filter::F = true_cmp) where {F,T}
if haskey(a.trees, query.seqname)
return ICTreeIntervalIntersectionIterator{F,T}(filter, ICTreeIntersection{T}(), a.trees[query.seqname], query)
end

return ICTreeIntervalIntersectionIterator{F,T}()
return ICTreeIntervalIntersectionIterator{F,T}(filter, ICTreeIntersection{T}(), ICTree{T}(), query)

end

function eachoverlap(a::IntervalCollection, b::IntervalCollection; filter = true_cmp)
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ end #testset Constructor Conversions
iter3 = eachoverlap(ic_a, intervals_b)
iter4 = eachoverlap(ic_a, ic_b)
@test collect(iter1) == collect(iter2) == collect(iter3) == collect(iter4)

# non-overlapping query
@test length(collect(eachoverlap(ic_a, Interval("X", 0, 0)))) == 0
end
end
end #testset GenomicFeatures

0 comments on commit 0091cb3

Please sign in to comment.