diff --git a/Project.toml b/Project.toml index 1eb4636..5b25a42 100644 --- a/Project.toml +++ b/Project.toml @@ -21,12 +21,12 @@ BioSequences = "3" DiscreteMarkovChains = "0.2" MarkovChainHammer = "0" PrecompileTools = "1" -VectorizedKmers = "0.8" +VectorizedKmers = "0.9" julia = "1" [extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test", "Aqua"] diff --git a/src/extended.jl b/src/extended.jl index 7c0c435..58bea4d 100644 --- a/src/extended.jl +++ b/src/extended.jl @@ -13,7 +13,7 @@ function Base.show( alphabet_type = eltype(model) # Print the type name with inferred alphabet type - println(io, "BioMarkovChain of $alphabet_type:") + println(io, "BioMarkovChain of $alphabet_type and order $(model.n):") # Print the transition probability matrix println(io, " - Transition Probability Matrix -> Matrix{Float64}($(size(model.tpm, 1)) × $(size(model.tpm, 2))):") @@ -42,25 +42,8 @@ function Base.show( for row in 1:size(model.inits, 1) println(io, " ", round(model.inits[row], digits=4)) end - - # Print the value of 'n' - println(io, " - Markov Chain Order -> Int64:") - println(io, " ", "$(model.n)") end @inline Base.length(bmc::BioMarkovChain) = length(bmc.inits) @inline Base.size(bmc::BioMarkovChain) = size(bmc.tpm) -@inline Base.eltype(bmc::BioMarkovChain) = bmc.alphabet - -""" - fit!(bmc::BMC, inits:Vector{Float64}, tpm::Matrix{Float64}) - -Update `bmc` in-place based on information generated from a state sequence. -""" -# function StatsAPI.fit!(bmc::BMC, inits::Vector{Float64}, tpm::Matrix{Float64}) -# bmc.inits .= inits -# sum_to_one!(bmc.inits) -# bmc.tpm .= tpm -# foreach(sum_to_one!, eachrow(bmc.tpm)) -# return nothing -# end \ No newline at end of file +@inline Base.eltype(bmc::BioMarkovChain) = bmc.alphabet \ No newline at end of file diff --git a/src/transitions.jl b/src/transitions.jl index d6115ea..f7f5553 100644 --- a/src/transitions.jl +++ b/src/transitions.jl @@ -22,13 +22,13 @@ tcm = transition_count_matrix(seq) 2 0 0 0 ``` """ -function transition_count_matrix(sequence::NucleicSeqOrView{A}) where A - counts = reshape(count_kmers(sequence, 2), (4,4))' +function transition_count_matrix(sequence::NucleicSeqOrView{A}) where {A} + counts = count_kmers(sequence, 2).values' return copy(counts) end function transition_count_matrix(sequence::SeqOrView{<:AminoAcidAlphabet}) - counts = reshape(count_kmers(sequence, 2), (20,20))' + counts = count_kmers(sequence, 2).values' return copy(counts) end