BioJulia/BioSequences.jl

Indexing with bool or integer vector does not work with seqview

jakobnissen opened this issue · 1 comments

MWE:

julia> x = view(dna"TAG", 1:3)
3nt DNA Sequence:
TAG

julia> x[[true, false, true]]
ERROR: MethodError: no method matching LongSubSeq{DNAAlphabet{4}}(::UndefInitializer, ::Int64)
Stacktrace:
 [1] getindex(x::LongSubSeq{DNAAlphabet{4}}, bools::Vector{Bool})
   @ BioSequences ~/code/BioSequences.jl/src/biosequence/indexing.jl:45
 [2] top-level scope
   @ REPL[2]:1

julia> x[collect(1:3)]
ERROR: MethodError: no method matching LongSubSeq{DNAAlphabet{4}}(::UndefInitializer, ::Int64)
Stacktrace:
 [1] getindex(x::LongSubSeq{DNAAlphabet{4}}, i::Vector{Int64})
   @ BioSequences ~/code/BioSequences.jl/src/biosequence/indexing.jl:59
 [2] top-level scope
   @ REPL[3]:1

No wait, this doesn't make any sense - these are not guaranteed to be contiguous in memory, and it's shady to materialize a full biosequence without the user asking for it.