Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix XOR hamming distance calculation #10

Closed
mchernys opened this issue Oct 18, 2024 · 2 comments
Closed

Fix XOR hamming distance calculation #10

mchernys opened this issue Oct 18, 2024 · 2 comments
Assignees

Comments

@mchernys
Copy link
Collaborator

No description provided.

@mashu mashu self-assigned this Oct 19, 2024
@mashu
Copy link
Owner

mashu commented Oct 19, 2024

Fixed by using mismatches from BioSequences

"""
    compute_distance(metric::DistanceMetric, x::LongDNA{4}, y::LongDNA{4})::Float32

Compute the distance between two `LongDNA{4}` sequences using the specified distance metric.
"""
function compute_distance(::NormalizedHammingDistance, x::LongDNA{4}, y::LongDNA{4})::Float32
    @assert length(x) == length(y)
    return mismatches(x, y) / length(x)
end

For the

x = LongDNA{4}(rand("ATGC",30))
y = LongDNA{4}(rand("ATGC",30))
@btime compute_distance_old($x, $y) # gave 91.649ns (6 allocations: 288 bytes)
@btime compute_distance_old($x, $y) # gave 4.125ns (0 allocations: 0 bytes)

This is therefore closed by 52b3783

@mashu mashu closed this as completed Oct 19, 2024
@mashu
Copy link
Owner

mashu commented Oct 19, 2024

Closed by 52b3783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants