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

Add SIMD hamming distance calculation #3

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Conversation

AlexTate
Copy link
Owner

@AlexTate AlexTate commented Dec 6, 2023

Hamming distance between two ShortSeqs can now be efficiently calculated with the XOR operator ^. SIMD instructions are used in the calculation so it should be quick, but there's room for improvement esp. for longer sequences. Will revisit the implementation if necessary once I have better benchmarks written.

sq1 = ShortSeq.from_str("ATGC")
sq2 = ShortSeq.from_str("ATCC")
sq1 ^ sq2 # returns 1

…ering bases between two sequences of equal length). Pop count is calculated using SIMD instructions and simple bitwise ops, so it should be pretty quick but I haven't run any benchmarks yet.
…rms random slicing all over a ShortSeqVar for extra assurance
@AlexTate AlexTate merged commit af1a11d into main Dec 6, 2023
6 checks passed
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

Successfully merging this pull request may close these issues.

1 participant