From 8a71715cd9fa3826da930f0caa965c109810232f Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Wed, 4 Jan 2023 14:16:48 -0600 Subject: [PATCH] Change `v::Haplotype` function arguments to `h::Haplotype` `v` made sense for a `Variant`, but doesn't for a `Haplotype`, so pretty things up. --- src/Haplotype.jl | 26 +++++++++++++------------- src/Variation.jl | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Haplotype.jl b/src/Haplotype.jl index 7412331..b989186 100644 --- a/src/Haplotype.jl +++ b/src/Haplotype.jl @@ -48,21 +48,21 @@ function Base.show(io::IO, x::Haplotype) end """ - is_valid(v::Haplotype) + is_valid(h::Haplotype) -Validate `v`. `v` is invalid if any of its operations are out of bounds, or the same +Validate `h`. `h` is invalid if any of its operations are out of bounds, or the same position is affected by multiple edits. """ -function _is_valid(v::Haplotype) - isempty(v.ref) && return false - valid_positions = 1:length(v.ref) +function _is_valid(h::Haplotype) + isempty(h.ref) && return false + valid_positions = 1:length(h.ref) last_was_insert = false - for edit in v.edits + for edit in h.edits pos = edit.pos op = edit.x # Sanity check: for this to be a valid variant, it must be comprised of valid # variations - _is_valid(Variation(v.ref, edit)) || return false + _is_valid(Variation(h.ref, edit)) || return false # For substitutions we simply do not allow another modification of the same base if op isa Substitution @@ -147,18 +147,18 @@ function Haplotype( end """ - _edits(v::Haplotype) + _edits(h::Haplotype) -Gets the [`Edit`](@ref)s that comprise `v` +Gets the [`Edit`](@ref)s that comprise `h` """ -_edits(v::Haplotype) = v.edits +_edits(h::Haplotype) = h.edits """ - reference(v::Haplotype) + reference(h::Haplotype) -Gets the reference sequence of `v`. +Gets the reference sequence of `h`. """ -reference(v::Haplotype) = v.ref +reference(h::Haplotype) = h.ref Base.:(==)(x::Haplotype, y::Haplotype) = x.ref == y.ref && x.edits == y.edits """ diff --git a/src/Variation.jl b/src/Variation.jl index 5121707..9be5d3a 100644 --- a/src/Variation.jl +++ b/src/Variation.jl @@ -171,14 +171,14 @@ function translate(var::Variation{S,T}, aln::PairwiseAlignment{S,S}) where {S,T} end """ - variations(v::Haplotype{S,T}) where {S,T} + variations(h::Haplotype{S,T}) where {S,T} -Converts the [`Edit`](@ref)s of `v` into a vector of [`Variation`](@ref)s. +Converts the [`Edit`](@ref)s of `h` into a vector of [`Variation`](@ref)s. """ -function variations(v::Haplotype{S,T}) where {S,T} - vs = Vector{Variation{S,T}}(undef, length(_edits(v))) - for (i, e) in enumerate(_edits(v)) - vs[i] = Variation{S,T}(reference(v), e) +function variations(h::Haplotype{S,T}) where {S,T} + vs = Vector{Variation{S,T}}(undef, length(_edits(h))) + for (i, e) in enumerate(_edits(h)) + vs[i] = Variation{S,T}(reference(h), e) end return vs end