mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-21 21:16:05 +00:00
Refactor Edit length to use dispatch instead of type checking
This commit is contained in:
parent
22d460b15a
commit
cab3029bc6
1 changed files with 2 additions and 1 deletions
|
@ -13,9 +13,10 @@ struct Edit{S<:BioSequence,T<:BioSymbol}
|
|||
x::Union{Substitution{T},Deletion,Insertion{S}}
|
||||
pos::UInt
|
||||
end
|
||||
|
||||
Base.length(e::Edit) = length(mutation(e))
|
||||
Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x
|
||||
Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h))
|
||||
Base.length(e::Edit) = e isa Substitution ? 1 : length(mutation(e))
|
||||
|
||||
function Base.parse(::Type{T}, s::AbstractString) where {T<:Edit{Se,Sy}} where {Se,Sy}
|
||||
return parse(T, String(s))
|
||||
|
|
Loading…
Reference in a new issue