diff --git a/src/Edit.jl b/src/Edit.jl index ecf2094..35dc062 100644 --- a/src/Edit.jl +++ b/src/Edit.jl @@ -1,14 +1,4 @@ -""" - Substitution - -Represents the presence of a `T` at a given position. The position is stored -outside this struct. -""" -struct Substitution{T<:BioSymbol} - x::T -end -Base.:(==)(x::Substitution, y::Substitution) = x.x == y.x -Base.hash(x::Substitution, h::UInt) = hash(Substitution, hash(x.x, h)) +include("edits/Substitution.jl") """ Deletion @@ -105,14 +95,6 @@ function lendiff(edit::Edit) return x isa Substitution ? 0 : (x isa Deletion ? -length(x) : length(x.x)) end -function _refbases(s::Substitution, reference::S, pos::UInt) where {S<:BioSequence} - return S([reference[pos]]) -end - -function _altbases(s::Substitution, reference::S, pos::UInt) where {S<:BioSequence} - return S([s.x]) -end - function _refbases(d::Deletion, reference::S, pos::UInt) where {S<:BioSequence} if pos == 1 return S(reference[UnitRange{Int}(pos, pos + length(d))]) diff --git a/src/edits/Substitution.jl b/src/edits/Substitution.jl new file mode 100644 index 0000000..e8101da --- /dev/null +++ b/src/edits/Substitution.jl @@ -0,0 +1,20 @@ +""" + Substitution + +Represents the presence of a `T` at a given position. The position is stored +outside this struct. +""" +struct Substitution{T<:BioSymbol} + x::T +end + +Base.:(==)(x::Substitution, y::Substitution) = x.x == y.x +Base.hash(x::Substitution, h::UInt) = hash(Substitution, hash(x.x, h)) + +function _refbases(s::Substitution, reference::S, pos::UInt) where {S<:BioSequence} + return S([reference[pos]]) +end + +function _altbases(s::Substitution, reference::S, pos::UInt) where {S<:BioSequence} + return S([s.x]) +end