mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-25 06:39: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 @@
|
||||||
"""
|
include("edits/Substitution.jl")
|
||||||
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))
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Deletion
|
Deletion
|
||||||
|
@ -105,14 +95,6 @@ function lendiff(edit::Edit)
|
||||||
return x isa Substitution ? 0 : (x isa Deletion ? -length(x) : length(x.x))
|
return x isa Substitution ? 0 : (x isa Deletion ? -length(x) : length(x.x))
|
||||||
end
|
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}
|
function _refbases(d::Deletion, reference::S, pos::UInt) where {S<:BioSequence}
|
||||||
if pos == 1
|
if pos == 1
|
||||||
return S(reference[UnitRange{Int}(pos, pos + length(d))])
|
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