Mark mutation(::Edit) as private API

This commit is contained in:
Thomas A. Christensen II 2023-01-03 20:00:42 -06:00
parent cb1c429610
commit e8457e4241
2 changed files with 7 additions and 7 deletions

View file

@ -14,7 +14,7 @@ struct Edit{S<:BioSequence,T<:BioSymbol}
pos::UInt pos::UInt
end end
Base.length(e::Edit) = length(mutation(e)) Base.length(e::Edit) = length(_mutation(e))
Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x Base.:(==)(e1::Edit, e2::Edit) = e1.pos == e2.pos && e1.x == e2.x
Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h)) Base.hash(x::Edit, h::UInt) = hash(Edit, hash((x.x, x.pos), h))
@ -42,17 +42,17 @@ function Base.parse(::Type{<:Edit{Se,Sy}}, s::Union{String,SubString{String}}) w
end end
end end
mutation(e::Edit) = e.x _mutation(e::Edit) = e.x
BioGenerics.leftposition(e::Edit) = e.pos BioGenerics.leftposition(e::Edit) = e.pos
function BioGenerics.rightposition(e::Edit) function BioGenerics.rightposition(e::Edit)
if mutation(e) isa Substitution if _mutation(e) isa Substitution
return leftposition(e) return leftposition(e)
elseif mutation(e) isa Insertion elseif _mutation(e) isa Insertion
return leftposition(e) + 1 return leftposition(e) + 1
elseif mutation(e) isa Deletion elseif _mutation(e) isa Deletion
return leftposition(e) + length(e) - 1 return leftposition(e) + length(e) - 1
else else
error("Unknown mutation type $(typeof(mutation(e)))") error("Unknown mutation type $(typeof(_mutation(e)))")
end end
end end

View file

@ -30,7 +30,7 @@ end
reference(v::Variation) = v.ref reference(v::Variation) = v.ref
edit(v::Variation) = v.edit edit(v::Variation) = v.edit
mutation(v::Variation) = mutation(edit(v)) mutation(v::Variation) = _mutation(edit(v))
BioGenerics.leftposition(v::Variation) = leftposition(edit(v)) BioGenerics.leftposition(v::Variation) = leftposition(edit(v))
BioGenerics.rightposition(v::Variation) = rightposition(edit(v)) BioGenerics.rightposition(v::Variation) = rightposition(edit(v))
Base.:(==)(x::Variation, y::Variation) = x.ref == y.ref && x.edit == y.edit Base.:(==)(x::Variation, y::Variation) = x.ref == y.ref && x.edit == y.edit