Skip to content

Commit

Permalink
Use naive hash fallback for BioSequence (#244)
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 #243
  • Loading branch information
jakobnissen authored Jul 5, 2022
1 parent 31936ce commit 9ec17a2
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
=#

2 comments on commit 9ec17a2

@jakobnissen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/63704

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.0.2 -m "<description of version>" 9ec17a24d50dc57315d71a2658fdddbe77175fda
git push origin v3.0.2

Please sign in to comment.