Skip to content

Commit

Permalink
Merge pull request #25 from camilogarciabotero:vkpatch
Browse files Browse the repository at this point in the history
Update tcm methods to new VK version
  • Loading branch information
camilogarciabotero authored Mar 26, 2024
2 parents 4ae649b + 79feb70 commit c2234c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
21 changes: 2 additions & 19 deletions src/extended.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))):")
Expand Down Expand Up @@ -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
@inline Base.eltype(bmc::BioMarkovChain) = bmc.alphabet
6 changes: 3 additions & 3 deletions src/transitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c2234c3

Please sign in to comment.