Skip to content

Commit 6f8c351

Browse files
author
Ben J. Ward
committed
Give BioSequences Base.IndexStyle, and Base.ndims.
1 parent eb6ead1 commit 6f8c351

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/biosequence/biosequence.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,17 @@ Base.keys(seq::BioSequence) = eachindex(seq)
4444
Base.nextind(::BioSequence, i::Integer) = Int(i) + 1
4545
Base.prevind(::BioSequence, i::Integer) = Int(i) - 1
4646
Base.size(x::BioSequence) = (length(x),)
47-
Base.ndims(x::BioSequence) = 1
47+
Base.ndims(::Type{<:BioSequence}) = 1
48+
Base.ndims(::T) where {T<:BioSequence} = 1
49+
Base.IndexStyle(x::BioSequence) = Base.IndexStyle(typeof(x))
50+
Base.IndexStyle(::Type{<:BioSequence}) = Base.IndexLinear()
4851
Base.eltype(::Type{<:BioSequence{A}}) where {A <: Alphabet} = eltype(A)
4952
Base.eltype(x::BioSequence) = eltype(typeof(x))
50-
Alphabet(::Type{<:BioSequence{A}}) where {A <: Alphabet} = A()
51-
Alphabet(x::BioSequence) = Alphabet(typeof(x))
5253
Base.isempty(x::BioSequence) = iszero(length(x))
5354
Base.empty(::Type{T}) where {T <: BioSequence} = T(eltype(T)[])
5455
Base.empty(x::BioSequence) = empty(typeof(x))
56+
Alphabet(::Type{<:BioSequence{A}}) where {A <: Alphabet} = A()
57+
Alphabet(x::BioSequence) = Alphabet(typeof(x))
5558
BitsPerSymbol(x::BioSequence) = BitsPerSymbol(Alphabet(typeof(x)))
5659

5760
function Base.similar(seq::BioSequence, len::Integer=length(seq))

0 commit comments

Comments
 (0)