@@ -27,7 +27,7 @@ function LongSequence{A}(it) where {A <: Alphabet}
2727 data = Vector {UInt64} (undef, seq_data_len (A, len))
2828 bits = zero (UInt)
2929 bitind = bitindex (BitsPerSymbol (A ()), encoded_data_eltype (LongSequence{A}), 1 )
30- @inbounds for (i, x) in enumerate (it)
30+ @inbounds for x in it
3131 xT = convert (eltype (A), x)
3232 enc = encode (A (), xT)
3333 bits |= enc << offset (bitind)
4444Base. empty (:: Type{T} ) where {T <: LongSequence } = T (UInt[], UInt (0 ))
4545(:: Type{T} )() where {T <: LongSequence } = empty (T)
4646
47+ # Constructors from other sequences
48+ # TODO : Remove this method, since the user can just slice
49+ LongSequence (s:: LongSequence , xs:: AbstractUnitRange{<:Integer} ) = s[xs]
50+
51+ function LongSequence (seq:: BioSequence{A} ) where {A <: Alphabet }
52+ return LongSequence {A} (seq)
53+ end
54+
55+ LongSequence {A} (seq:: LongSequence{A} ) where {A <: Alphabet } = copy (seq)
56+
57+ function (:: Type{T} )(seq:: LongSequence{<:NucleicAcidAlphabet{N}} ) where
58+ {N, T<: LongSequence{<:NucleicAcidAlphabet{N}} }
59+ return T (copy (seq. data), seq. len)
60+ end
61+
62+ # Constructors from strings
4763function LongSequence {A} (s:: Union{String, SubString{String}} ) where {A<: Alphabet }
4864 return LongSequence {A} (s, codetype (A ()))
4965end
@@ -69,21 +85,4 @@ function LongSequence{A}(
6985 return copyto! (seq, 1 , src, first (part), len)
7086end
7187
72- # create a subsequence
73- function LongSequence (other:: LongSequence , part:: AbstractUnitRange{<:Integer} )
74- checkbounds (other, part)
75- subseq = typeof (other)(undef, length (part))
76- copyto! (subseq, 1 , other, first (part), length (part))
77- return subseq
78- end
79-
80- function LongSequence (seq:: BioSequence{A} ) where {A <: Alphabet }
81- return LongSequence {A} (seq)
82- end
83-
84- LongSequence {A} (seq:: LongSequence{A} ) where {A <: Alphabet } = copy (seq)
85-
86- function (:: Type{T} )(seq:: LongSequence{<:NucleicAcidAlphabet{N}} ) where
87- {N, T<: LongSequence{<:NucleicAcidAlphabet{N}} }
88- return T (copy (seq. data), seq. len)
89- end
88+ Base. parse (:: Type{LongSequence{A}} , seq:: AbstractString ) where A = LongSequence {A} (seq)
0 commit comments