Skip to content

Commit

Permalink
hotfix for reverse_complementing a slice of a longseq (#111)
Browse files Browse the repository at this point in the history
* hotfix for reverse_complementing a slice of a longseq

* Implement shallow copy fix proposed by BenJWard
  • Loading branch information
cjprybol authored Jun 24, 2020
1 parent 01fbc26 commit 312e274
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/longsequences/transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ function reverse_complement!(seq::LongSequence{<:NucleicAcidAlphabet})
end

function reverse_complement(seq::LongSequence{<:NucleicAcidAlphabet})
cp = typeof(seq)(unsigned(length(seq)))
pred = x -> complement_bitpar(x, Alphabet(seq))
reverse_data_copy!(pred, cp.data, seq.data, BitsPerSymbol(seq))
return zero_offset!(cp)
return reverse_complement!(copy(seq))
end

###
Expand Down
2 changes: 2 additions & 0 deletions test/longsequences/transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
@test String(seq) == seq_string
@test String(seq2) == reverse(dna_complement(seq_string[100:200]))

slice = randdnaseq(10)[2:9]
@test reverse_complement(reverse_complement(slice)) == slice
end

@testset "Map" begin
Expand Down

0 comments on commit 312e274

Please sign in to comment.