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.
We will think of RNA as a long string over the alphabet of base pairs,
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
Each codon (except the stop codons) corresponds to an amino acid, and the resulting string of amino acids forms the protein.
Your input is a non-empty string of RNA.
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.
Consider the input sequence
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
For the shorter input
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.
GGUACGGAUU -> GGCGAAAUCGAUGCC -> AUG ACAUGGAUGGACUGU -> AUG,GAU,GGA,CUG AUGACGUGAUGCUUGA -> AUG,ACG UGGUUAGAAUAAUGAGCUAG -> AUG,AGC ACAUGGAUGGACUGUAACCCCAUGC -> AUG,GAU,GGA,CUG CUAAGAUGGCAUGAGUAAUGAAUGGAG -> AUG,GCA AAUGGUUUAAUAAAUGUGAUAUGAUGAUA -> AUG,GUU UGUCACCAUGUAAGGCAUGCCCAAAAUCAG -> AUG UAUAGAUGGUGAUGAUGCCAUGAGAUGCAUGUUAAU -> AUG,GUG,AUG,AUG,CCA AUGCUUAUGAAUGGCAUGUACUAAUAGACUCACUUAAGCGGUGAUGAA -> AUG,CUU,AUG,AAU,GGC,AUG,UAC UGAUAGAUGUAUGGAUGGGAUGCUCAUAGCUAUAAAUGUUAAAGUUAGUCUAAUGAUGAGUAGCCGAUGGCCUAUGAUGCUGAC -> AUG,UAU,GGA,UGG,GAU,GCU,CAU,AGC,UAU,AAA,UGU