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

Allow hamming circle around N #126

Merged
merged 2 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/demultiplexer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function hamming_circle(seq, m)
for rs in Iterators.product(fill(1:4, m)...)
seqβ€² = copy(seq)
for (p, r) in zip(ps, rs)
if findfirst(isequal(seq[p]), ACGT) ≀ r
if findfirst(isequal(seq[p]), ACGTN) ≀ r
r += 1
end
seqβ€²[p] = ACGTN[r]
Expand Down
18 changes: 18 additions & 0 deletions test/demultiplexer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,22 @@
@test n_ok / 10_000 > 0.99
@test n_ok < n_ok_with_fallback
end

@testset "Hamming circle" begin
@test sort(BioSequences.hamming_circle(dna"A",1)) == [dna"C",dna"G",dna"T",dna"N"]
@test sort(BioSequences.hamming_circle(dna"N",1)) == [dna"A",dna"C",dna"G",dna"T"]
end
@testset "Levenshtein circle" begin
@test sort(BioSequences.levenshtein_circle(dna"A",1)) == [dna"", dna"C", dna"CA", dna"G", dna"GA", dna"T", dna"TA", dna"N", dna"NA"]
@test sort(BioSequences.levenshtein_circle(dna"N",1)) == [dna"", dna"A", dna"AN", dna"C", dna"CN", dna"G", dna"GN", dna"T", dna"TN"]
end
@testset "Levenshtein distance 2" begin
barcodes = [dna"ATGGC", dna"GGAAG"]
dplxr2 = Demultiplexer(barcodes, n_max_errors=2, distance=:levenshtein)

@test demultiplex(dplxr2, dna"ATGGC") === (1, 0)
@test demultiplex(dplxr2, dna"ATGG") === (1, 1)
@test demultiplex(dplxr2, dna"ATG") === (1, 2)
@test demultiplex(dplxr2, dna"TACG") === (0, -1)
end
end