-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ordering of genomic intervals only works as expected when parameterised by the same type #44
Comments
I think I've got upstream code that addresses your use case. But let me know if it doesn't and I'll have another look at your suggestion. I've linked the relevant code below. GenomicFeatures.jl/src/interval.jl Lines 86 to 137 in 2bad569
If you want to test the code, add the following packages. add https://github.com/CiaranOMara/IntervalTrees.jl#pu/v1.1.0
add GenomicFeatuers#pu/v3.0.0 The main changes are that the These branches are fairly stable as I'm using them for my own work. The reason they haven't been merged into master is that it doesn't seem correct/reasonable to run ahead with GenomicFeatures v3 before bring all of the other packages up to date with GenomicFeatures v2. |
I've moved the relevant code down to the head of the develop branch. So the functionality you require without the new types is now also an option for you with |
Comparison of intervals
isless
,isordered
,precedes
of intervals is defined for intervals with identical type parameters for their metadata, for example:Base.isless(a::Interval{T}, b::Interval{T}, seqname_isless::Function=isless) where T
This causes some surprises when comparing intervals with different parametric types as it falls back on
basic_isless
defined inIntervalTrees.jl
and does not compareseqname
:It would be super useful to be able to order intervals when their metadata was of different types. The most obvious change would be to allow different type parameters:
Base.isless(a::Interval{T}, b::Interval{V}, seqname_isless::Function=isless) where {T, V}
However, could this cause issues breaking ordering equality conditions, as it makes sense to define isequal for two intervals that have equal metadata. So for two intervals
x
andy
with identical coordinates but different metadata you would have all ofisless(x, y)
,isless(y, x)
andisequal(x, y)
being false.My use case is that I want to calculate distances between intervals with different metadata and using functions like
sort
andsearchsorted
are useful in doing this.Would be happy if
isordered
was changed toisordered(a::Interval{T}, b::Interval{V}, seqname_isless::Function=isless) where {T, V}
, and then use:searchsorted(intervals, iv, lt=GenomicFeatures.isordered)
, unless anyone sees any issues in doing so?The text was updated successfully, but these errors were encountered: