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

getindex not defined for arrays #61

Closed
diegozea opened this issue May 7, 2019 · 5 comments
Closed

getindex not defined for arrays #61

diegozea opened this issue May 7, 2019 · 5 comments
Labels
feature request A request for some desired or missing functionality

Comments

@diegozea
Copy link
Member

diegozea commented May 7, 2019

I was trying to create a sequence without some index and I've found that getindex using arrays isn't supported:

using BioSequences
seq = dna"CCTAGGAGG"
seq[[1,2,3,7,8,9]] # MethodError
seq[[true, true, true, false, false, false, true, true, true]] # MethodError
@TransGirlCodes TransGirlCodes added the feature request A request for some desired or missing functionality label May 10, 2019
@TransGirlCodes
Copy link
Member

Thanks for pointing this out @diegozea, perhaps we can include this method in version 2.0.

@ardakdemir
Copy link
Member

ardakdemir commented May 13, 2019

I have been going over the source code to get familiar and to add this functionality. I could not understand how the decode function call in indexing.jl properly decodes the given Int representation. I could not find a decode function in the source code. Below is the corresponding code from indexing.jl:

@inline function inbounds_getindex(seq::BioSequence{A}, i::Integer) where {A}
    j = bitindex(seq, i)
    @inbounds return decode(A, (seq.data[index(j)] >> offset(j)) & mask(A))
end

@TransGirlCodes
Copy link
Member

TransGirlCodes commented May 13, 2019

@ardakdemir The definitions for encode and decode are found here in the body of this loop

for A in (DNAAlphabet, RNAAlphabet)
. How encoding and decoding is done, depends on the alphabet parameter A of the BioSequence{A}, and so A is the first argument to the decode method, so as Julia's compiler can select the correct decode method at compile time.

@ardakdemir
Copy link
Member

@benjward Thanks for the explanation. @diegozea I have added a trivial implementation of subsequencing functionality on the "subsequencing" branch. Maybe you can give it a try.

@jakobnissen
Copy link
Member

This appears to be fixed on master, so closing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request for some desired or missing functionality
Projects
None yet
Development

No branches or pull requests

4 participants