Skip to content

Commit

Permalink
Merge pull request #43 from jakobnissen/removeiter
Browse files Browse the repository at this point in the history
Remove iteration of BioSymbol
  • Loading branch information
jakobnissen authored Mar 21, 2021
2 parents 4d11c1e + 698855b commit 6f0180f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/BioSymbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ encoded_data(x::BioSymbol) = reinterpret(encoded_data_eltype(typeof(x)), x)
function encode(::Type{T}, x) where T <: BioSymbol
return reinterpret(T, convert(encoded_data_eltype(T), x))
end
Base.length(::BioSymbol) = 1
Base.iterate(sym::BioSymbol) = (sym, nothing)
Base.iterate(sym::BioSymbol, state) = nothing

# Enable broadcasting
Base.broadcastable(x::BioSymbol) = (x,)

include("nucleicacid.jl")
include("aminoacid.jl")
Expand Down
23 changes: 8 additions & 15 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@ function round_trip(x)
return x == y
end

@testset "BioSymbols" begin
for i in alphabet(DNA)
@test length(i) == 1
@test collect(i) == [i]
end
for i in alphabet(RNA)
@test length(i) == 1
@test collect(i) == [i]
end
for i in alphabet(AminoAcid)
@test length(i) == 1
@test collect(i) == [i]
end
end

@testset "NucleicAcids" begin
@testset "Conversions" begin
@testset "UInt8" begin
Expand Down Expand Up @@ -296,6 +281,14 @@ end
end
end

@testset "Broadcasting" begin
v = DNA[DNA_A, DNA_C, DNA_G, DNA_C]
v[2:3] .= DNA_A
@test v == [DNA_A, DNA_A, DNA_A, DNA_C]
v .= DNA_T
@test v == fill(DNA_T, 4)
end

@testset "Show DNA" begin
dnas = [DNA_A, DNA_C, DNA_G, DNA_T, DNA_N, DNA_Gap]
@testset "print" begin
Expand Down

0 comments on commit 6f0180f

Please sign in to comment.