mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-24 22:29:55 +00:00
Move Substitution-related code to edits/Substitution.jl
This commit is contained in:
parent
8c2dd271f3
commit
ba9f0e8fb1
2 changed files with 21 additions and 19 deletions
20
src/Edit.jl
20
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))])
|
||||
|
|
20
src/edits/Substitution.jl
Normal file
20
src/edits/Substitution.jl
Normal file
|
@ -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
|
Loading…
Reference in a new issue