@@ -324,17 +324,9 @@ Base3 = TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG
324324# ##
325325
326326"""
327- translate(seq, code=standard_genetic_code, allow_ambiguous_codons=true, alternative_start=false)
327+ translate(seq; kwargs...)::LongAA
328328
329- Translate an `LongRNA` or a `LongDNA` to an `LongAA`.
330-
331- Translation uses genetic code `code` to map codons to amino acids. See
332- `ncbi_trans_table` for available genetic codes.
333- If codons in the given sequence cannot determine a unique amino acid, they
334- will be translated to `AA_X` if `allow_ambiguous_codons` is `true` and otherwise
335- result in an error. For organisms that utilize alternative start codons, one
336- can set `alternative_start=true`, in which case the first codon will always be
337- converted to a methionine.
329+ Same as [`translate!`](@ref), but allocate a new `LongAA` to hold the result.
338330"""
339331function translate (ntseq:: SeqOrView ;
340332 code:: GeneticCode = standard_genetic_code,
@@ -346,6 +338,58 @@ function translate(ntseq::SeqOrView;
346338 allow_ambiguous_codons = allow_ambiguous_codons, alternative_start = alternative_start)
347339end
348340
341+ """
342+ translate!(
343+ aaseq::LongAA,
344+ seq::Union{LongSequence, LongSubSeq};
345+ code::BioSequences.GeneticCode=BioSequences.standard_genetic_code,
346+ allow_ambiguous_codons::Bool=true,
347+ alternative_start::Bool=false
348+ ) -> aaseq
349+
350+ Translate a nucleotide sequence in-place into `aaseq`, resizing `aaseq` to fit,
351+ and return `aaseq`.
352+
353+ # Examples
354+ ```jldoctest
355+ julia> translate!(aa"", dna"TCTACACCCTAG")
356+ 4aa Amino Acid Sequence:
357+ STP*
358+
359+ julia> translate!(aa"", dna"TA")
360+ ERROR: LongRNA length is not divisible by three. Cannot translate.
361+ [...]
362+
363+ julia> translate!(aa"", dna"A-A")
364+ ERROR: Cannot translate nucleotide sequences with gaps.
365+ [...]
366+
367+ julia> translate!(aa"", dna"AAAACWGCSWTARACADA"; alternative_start=true)
368+ 6aa Amino Acid Sequence:
369+ MTAJBX
370+ ```
371+
372+ # Extended help
373+
374+ `seq` must be either `LongSequence` or `LongSubSeq`
375+ of alphabets either `DNAAlphabet` or `RNAAlphabet`.
376+
377+ Translation is done using genetic code `code`, which defaults to the standard
378+ genetic code.
379+
380+ If the length of `seq` is not divisible by 3, throw an error.
381+
382+ If `seq` contains any gaps (i.e. `DNA_Gap` or `RNA_Gap`), throw an error.
383+
384+ If `allow_ambiguous_codons` is set (default), codons with ambiguous nucleotides
385+ such as `DNA_W` will be translated to the most narrow amino acid which covers all
386+ non-ambiguous codons encompassed by the ambiguous codon. This process might slow
387+ translation down.
388+ If not `allow_ambiguous_codons`, ambiguous codons will error.
389+
390+ If `alternative_start` is set, the leading methionine will be set to `AA_M`, no
391+ matter the starting codon, or the code.
392+ """
349393function translate! (aaseq:: LongAA ,
350394 ntseq:: SeqOrView{<:NucleicAcidAlphabet{2}} ;
351395 code:: GeneticCode = standard_genetic_code,
0 commit comments