mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-29 07:59:55 +00:00
feat: Add SubstitutionEdit type
This commit is contained in:
parent
9d882fb1d8
commit
3eab426398
1 changed files with 22 additions and 0 deletions
22
src/Edit.jl
22
src/Edit.jl
|
@ -62,6 +62,28 @@ Base.hash(x::InsertionEdit, h::UInt) = hash(InsertionEdit, hash((x.position, x.s
|
|||
BioGenerics.leftposition(i::InsertionEdit) = i.position
|
||||
BioGenerics.rightposition(i::InsertionEdit) = leftposition(i) + 1
|
||||
|
||||
struct SubstitutionEdit{S<:BioSequence,T<:BioSymbol} <: Edit{S,T}
|
||||
position::UInt
|
||||
base::T
|
||||
|
||||
function SubstitutionEdit{T}(position::UInt, base::T) where {T<:BioSymbol}
|
||||
iszero(position) &&
|
||||
function SubstitutionEdit{S,T}(
|
||||
position::UInt, base::T
|
||||
) where {S<:BioSequence,T<:BioSymbol}
|
||||
return new(position, base)
|
||||
end
|
||||
end
|
||||
Base.length(s::SubstitutionEdit) = 1
|
||||
function Base.:(==)(x::SubstitutionEdit, y::SubstitutionEdit)
|
||||
return x.position == y.position && x.base == y.base
|
||||
end
|
||||
function Base.hash(x::SubstitutionEdit, h::UInt)
|
||||
return hash(SubstitutionEdit, hash((x.position, x.base), h))
|
||||
end
|
||||
BioGenerics.leftposition(s::SubstitutionEdit) = s.position
|
||||
BioGenerics.rightposition(s::SubstitutionEdit) = leftposition(s)
|
||||
|
||||
function Base.parse(::Type{T}, s::AbstractString) where {T<:Edit{Se,Sy}} where {Se,Sy}
|
||||
return parse(T, String(s))
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue