mirror of
https://github.com/MillironX/SequenceVariation.jl.git
synced 2024-11-25 22:59:56 +00:00
refactor: Change Edit parsing to return *Edit types
This commit is contained in:
parent
3eab426398
commit
f5bfd78020
1 changed files with 3 additions and 3 deletions
|
@ -94,15 +94,15 @@ function Base.parse(::Type{<:Edit{Se,Sy}}, s::Union{String,SubString{String}}) w
|
||||||
pos = parse(UInt, m[1])
|
pos = parse(UInt, m[1])
|
||||||
stop = parse(UInt, m[2])
|
stop = parse(UInt, m[2])
|
||||||
stop ≥ pos || throw(ArgumentError("Non-positive deletion length: \"" * s * "\""))
|
stop ≥ pos || throw(ArgumentError("Non-positive deletion length: \"" * s * "\""))
|
||||||
Edit{Se,Sy}(Deletion(stop - pos + 1), pos)
|
return DeletionEdit{Se,Sy}(pos, stop - pos + 1)
|
||||||
elseif (m = match(r"^(\d+)([A-Za-z]+)$", s); m) !== nothing
|
elseif (m = match(r"^(\d+)([A-Za-z]+)$", s); m) !== nothing
|
||||||
pos = parse(UInt, m[1])
|
pos = parse(UInt, m[1])
|
||||||
seq = Se(m[2])
|
seq = Se(m[2])
|
||||||
Edit{Se,Sy}(Insertion(seq), pos)
|
return InsertionEdit{Se,Sy}(pos, seq)
|
||||||
elseif (m = match(r"^[A-Za-z](\d+)([A-Za-z])$", s); m) !== nothing
|
elseif (m = match(r"^[A-Za-z](\d+)([A-Za-z])$", s); m) !== nothing
|
||||||
pos = parse(UInt, m[1])
|
pos = parse(UInt, m[1])
|
||||||
sym = Sy(first(m[2]))
|
sym = Sy(first(m[2]))
|
||||||
Edit{Se,Sy}(Substitution(sym), pos)
|
return SubstitutionEdit{Se,Sy}(pos, sym)
|
||||||
else
|
else
|
||||||
throw(ArgumentError("Failed to parse edit \"" * s * '"'))
|
throw(ArgumentError("Failed to parse edit \"" * s * '"'))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue