Skip to content

Commit

Permalink
Use naive hash fallback for BioSequence
Browse files Browse the repository at this point in the history
Current hashing behaviour hashes equal biosequences with different encodings to
different values, which violate the interface of hash.
This is a fix until (and if) we figure out a better method of hashing.

See issue BioJulia#243
  • Loading branch information
jakobnissen committed Jul 5, 2022
1 parent 31936ce commit d4700a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BioSequences"
uuid = "7e6ae17a-c86d-528c-b3b9-7f778a29fe59"
authors = ["Sabrina Jaye Ward <[email protected]>", "Jakob Nissen <[email protected]>"]
version = "3.0.1"
version = "3.0.2"

[deps]
BioSymbols = "3c28c6f8-a34d-59c4-9654-267d177fcfa9"
Expand Down
1 change: 1 addition & 0 deletions src/biosequence/biosequence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Base.isempty(x::BioSequence) = iszero(length(x))
Base.empty(::Type{T}) where {T <: BioSequence} = T(eltype(T)[])
Base.empty(x::BioSequence) = empty(typeof(x))
BitsPerSymbol(x::BioSequence) = BitsPerSymbol(Alphabet(typeof(x)))
Base.hash(s::BioSequence, x::UInt) = foldl((a, b) -> hash(b, a), s, init=x)

function Base.similar(seq::BioSequence, len::Integer=length(seq))
return typeof(seq)(undef, len)
Expand Down
3 changes: 3 additions & 0 deletions src/longsequences/hash.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
### This file is a part of BioJulia.
### License is MIT: https://github.com/BioJulia/BioSequences.jl/blob/master/LICENSE.md

# NB NOTE: This entire file is commented out until issue #243 is resolved
#=
const c1 = 0x87c37b91114253d5
const c2 = 0x4cf5ad432745937f
Expand Down Expand Up @@ -173,3 +175,4 @@ function Base.hash(seq::SeqOrView, seed::UInt64)
return h1
end
=#

0 comments on commit d4700a9

Please sign in to comment.