refactor: Add Base methods for generic Edit

This commit is contained in:
Thomas A. Christensen II 2024-10-01 10:38:47 -05:00
parent 0b10b9ae7b
commit 1c80158d5b
Signed by: millironx
GPG key ID: B7044A3432851F64

View file

@ -11,9 +11,10 @@ If insertion: Insertion of length L b/w ref pos `pos:pos+1`
""" """
abstract type Edit{S<:BioSequence,T<:BioSymbol} end abstract type Edit{S<:BioSequence,T<:BioSymbol} end
Base.length(e::Edit) = length(_mutation(e)) Base.length(e::Edit) = error("length not implemented for type $(typeof(e))")
Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x Base.:(==)(e1::Edit, e2::Edit) = typeof(e1) == typeof(e2) && e1 == e2
Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h)) Base.hash(x::Edit, h::UInt) = error("hash not implemented for type $(typeof(x))")
function Base.isless(x::Edit, y::Edit) function Base.isless(x::Edit, y::Edit)
if leftposition(x) == leftposition(y) if leftposition(x) == leftposition(y)
return length(x) < length(y) return length(x) < length(y)