Parse RNA into codons Introduction

RNA is the less famous cousin of DNA.
Its main purpose is to control the production of proteins in cells through a process called translation.
In this challenge, your task is to implement a part of this process where the RNA is split into codons.

This challenge is thematically related, but concentrates on another part of the translation process.

Codons

We will think of RNA as a long string over the alphabet of base pairs, AUCG.
In translation, RNA is split into non-overlapping chunks of three base pairs, called codons.
The process begins at a start codon, AUG, and ends at a stop codon, one of UAA, UAG or UGA.
Each codon (except the stop codons) corresponds to an amino acid, and the resulting string of amino acids forms the protein.

Input

Your input is a non-empty string of RNA.

Output

Your output is the list of codons in which the RNA is split, in any reasonable format.
In this simplified model, the process begins at the leftmost start codon AUG, which is included in the output.
It ends when a stop codon is encountered, or when we run out of RNA.
If the input contains no start codon, the output shall be an empty list.

Examples

Consider the input sequence

ACAUGGAUGGACUGUAACCCCAUGC


The parsing begins at the leftmost occurrence of AUG, at index 2.
It continues as follows:

AC AUG GAU GGA CUG UAA CCCCAUGC
   *   ^   ^   ^   +


The codon marked with * is the start codon, and those marked with ^ are also part of the output.
The stop codon is marked with +.
The correct output is

AUG,GAU,GGA,CUG


For the shorter input

ACAUGGAUGGACUGU


the process goes

AC AUG GAU GGA CUG U
   *   ^   ^   ^


This time, a stop codon is not encountered, so the process stops when we run out of base pairs.
The output is the same as above.

Rules and scoring

You can write a full program of a function.
The lowest byte count wins, and standard loopholes are disallowed.

Test cases

GGUACGGAUU -&gt; 
GGCGAAAUCGAUGCC -&gt; AUG
ACAUGGAUGGACUGU -&gt; AUG,GAU,GGA,CUG
AUGACGUGAUGCUUGA -&gt; AUG,ACG
UGGUUAGAAUAAUGAGCUAG -&gt; AUG,AGC
ACAUGGAUGGACUGUAACCCCAUGC -&gt; AUG,GAU,GGA,CUG
CUAAGAUGGCAUGAGUAAUGAAUGGAG -&gt; AUG,GCA
AAUGGUUUAAUAAAUGUGAUAUGAUGAUA -&gt; AUG,GUU
UGUCACCAUGUAAGGCAUGCCCAAAAUCAG -&gt; AUG
UAUAGAUGGUGAUGAUGCCAUGAGAUGCAUGUUAAU -&gt; AUG,GUG,AUG,AUG,CCA
AUGCUUAUGAAUGGCAUGUACUAAUAGACUCACUUAAGCGGUGAUGAA -&gt; AUG,CUU,AUG,AAU,GGC,AUG,UAC
UGAUAGAUGUAUGGAUGGGAUGCUCAUAGCUAUAAAUGUUAAAGUUAGUCUAAUGAUGAGUAGCCGAUGGCCUAUGAUGCUGAC -&gt; AUG,UAU,GGA,UGG,GAU,GCU,CAU,AGC,UAU,AAA,UGU
Retina, 39 38 32 30 bytes

M!`AUG|\B\G...
U(AA|AG|GA)\D*



The trailing linefeed is significant.

Output as a linefeed-separated list.

Try it online.

Explanation

M!`AUG|\B\G...


This is match stage which turns the input into a linefeed-separated list of all matches (due to the !). The regex itself matches every codon starting from the first AUG. We achieve this with two separate options. AUG matches unconditionally, so that it can start the list of matches. The second match can be any codon (... matches any three characters), but the \G is a special anchor which ensures that this can only match right after another match. The only problem is that \G also matches at the beginning of the string, which we don't want. Since the input consists only of word characters, we use \B (any position that is not a word boundary) to ensure that this match is not used at the beginning of the input.

U(AA|AG|GA)\D*



This finds the first stop codon, matched as U(AA|AG|GA) as well as everything after it and removes it from the string. Since the first stage split the codons into separate lines, we know that this match is properly aligned with the start codon. We use \D (non-digits) to match any character, since . wouldn't go past the linefeeds, and the input won't contain digits.