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+ function LongSequence (other:: LongSequence , part:: AbstractUnitRange{<:Integer} )
50+ checkbounds (other, part)
51+ subseq = typeof (other)(undef, length (part))
52+ copyto! (subseq, 1 , other, first (part), length (part))
53+ return subseq
54+ end
55+
56+ function LongSequence (seq:: BioSequence{A} ) where {A <: Alphabet }
57+ return LongSequence {A} (seq)
58+ end
59+
60+ LongSequence {A} (seq:: LongSequence{A} ) where {A <: Alphabet } = copy (seq)
61+
62+ function (:: Type{T} )(seq:: LongSequence{<:NucleicAcidAlphabet{N}} ) where
63+ {N, T<: LongSequence{<:NucleicAcidAlphabet{N}} }
64+ return T (copy (seq. data), seq. len)
65+ end
66+
67+ # Constructors from strings
4768function LongSequence {A} (s:: Union{String, SubString{String}} ) where {A<: Alphabet }
4869 return LongSequence {A} (s, codetype (A ()))
4970end
@@ -69,21 +90,4 @@ function LongSequence{A}(
6990 return copyto! (seq, 1 , src, first (part), len)
7091end
7192
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
93+ Base. parse (:: Type{LongSequence{A}} , seq:: AbstractString ) where A = LongSequence {A} (seq)
0 commit comments