diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} diff --git a/src/Edit.jl b/src/Edit.jl index cf4bab0..1c55dab 100644 --- a/src/Edit.jl +++ b/src/Edit.jl @@ -46,6 +46,22 @@ Base.hash(x::DeletionEdit, h::UInt) = hash(DeletionEdit, hash((x.position, x.len BioGenerics.leftposition(d::DeletionEdit) = d.position BioGenerics.rightposition(d::DeletionEdit) = leftposition(d) + length(d) - 1 +struct InsertionEdit{S<:BioSequence,T<:BioSymbol} <: Edit{S,T} + position::UInt + seq::S + + function InsertionEdit{S}(position::UInt, seq::S) where {S<:BioSequence} + iszero(position) && error("Insertion cannot be at a position outside the sequence") + function InsertionEdit{S,T}(position::UInt, seq::S) where {S<:BioSequence,T<:BioSymbol} + return new(position, seq) + end +end +Base.length(i::InsertionEdit) = length(i.seq) +Base.:(==)(x::InsertionEdit, y::InsertionEdit) = x.position == y.position && x.seq == y.seq +Base.hash(x::InsertionEdit, h::UInt) = hash(InsertionEdit, hash((x.position, x.seq), h)) +BioGenerics.leftposition(i::InsertionEdit) = i.position +BioGenerics.rightposition(i::InsertionEdit) = leftposition(i) + 1 + function Base.parse(::Type{T}, s::AbstractString) where {T<:Edit{Se,Sy}} where {Se,Sy} return parse(T, String(s)) end diff --git a/structure.png b/structure.png new file mode 100644 index 0000000..7c0e942 Binary files /dev/null and b/structure.png differ