diff --git a/src/construction.jl b/src/construction.jl index 032c3aa..af8834c 100644 --- a/src/construction.jl +++ b/src/construction.jl @@ -109,91 +109,6 @@ include("construction_utils.jl") throw(BioSequences.EncodeError(A, reinterpret(T, enc % UInt8))) end -#= -"Extract a full kmer at a given index of a sequence. -Note: These methods don't do any bounds checking" -function unsafe_extract end - -@inline function unsafe_extract( - ::TwoToFour, - ::Type{T}, - seq::BioSequence, - from_index, -) where {T <: Kmer} - data = zero_tuple(T) - for i in from_index:(from_index + ksize(T) - 1) - encoding = left_shift(UInt(1), UInt(BioSequences.extract_encoded_element(seq, i))) - (_, data) = leftshift_carry(data, 4, encoding) - end - T(unsafe, data) -end - -@inline function unsafe_extract( - ::FourToTwo, - ::Type{T}, - seq::BioSequence, - from_index, -) where {T <: Kmer} - data = zero_tuple(T) - for i in from_index:(from_index + ksize(T) - 1) - encoding = UInt(BioSequences.extract_encoded_element(seq, i))::UInt - isone(count_ones(encoding)) || throw_uncertain(Alphabet(T), eltype(seq), encoding) - (_, data) = leftshift_carry(data, 2, trailing_zeros(encoding) % UInt) - end - T(unsafe, data) -end - -@inline function unsafe_extract( - ::Copyable, - ::Type{T}, - seq::BioSequence, - from_index, -) where {T <: Kmer} - data = zero_tuple(T) - bps = BioSequences.bits_per_symbol(Alphabet(seq)) - for i in from_index:(from_index + ksize(T) - 1) - encoding = UInt(BioSequences.extract_encoded_element(seq, i))::UInt - (_, data) = leftshift_carry(data, bps, encoding) - end - T(unsafe, data) -end - -@inline function unsafe_extract( - ::AsciiEncode, - ::Type{T}, - seq::AbstractVector{UInt8}, - from_index, -) where {T <: Kmer} - data = zero_tuple(T) - bps = BioSequences.bits_per_symbol(Alphabet(T)) - @inbounds for i in from_index:(from_index + ksize(T) - 1) - byte = seq[i] - encoding = BioSequences.ascii_encode(Alphabet(T), byte) - if encoding > 0x7f - throw(BioSequences.EncodeError(Alphabet(T), byte)) - end - (_, data) = leftshift_carry(data, bps, encoding % UInt) - end - T(unsafe, data) -end - -@inline function unsafe_extract( - ::GenericRecoding, - ::Type{T}, - seq, - from_index, -) where {T <: Kmer} - data = zero_tuple(T) - bps = BioSequences.bits_per_symbol(Alphabet(T)) - @inbounds for i in 1:ksize(T) - symbol = convert(eltype(T), seq[i]) - encoding = UInt(BioSequences.encode(Alphabet(T), symbol)) - (_, data) = leftshift_carry(data, bps, encoding) - end - T(unsafe, data) -end -=# - ################################################ # Constructors with full parameterisation ################################################