BioJulia/BioSequences.jl

What happened to DNAMer?

JokingHero opened this issue · 1 comments

I have been using DNAMer for trick like this:

function Base.convert(::Type{UInt64}, x::LongDNASeq)
    return BioSequences.encoded_data(DNAMer(x))
end

@inline function BioSequences.LongDNASeq(x::UInt64, len::Int)
    return LongDNASeq(DNAMer{len}(x))
end

I think with update to v3 it got removed. And I am not so sure how to achieve the same with the v3...
I was thinking the code below should work, but something is changed and I am unable to pinpoint the problem.

function Base.convert(::Type{UInt64}, x::LongDNA{4})
    x = LongDNA{2}(x)
    if (length(x.data) > 1) 
        throw("Sequence too long to save as UInt64.")
    end
    return UInt64(x.data[1])
end

@inline function BioSequences.LongDNA{4}(x::UInt64, len::Int)
    return LongDNA{4}(LongDNA{2}([x], UInt64(len)))
end

Can someone give advice?

Kmers are being revamped and redone in a new package - Kmers.jl, they will be based on NTuples and so allow for larger values of K than were previously possible. Your code in the second block looks sensible to me.