Skip to content

Commit 0ff3ac6

Browse files
add more examples of ambiguous codons and mrna strands not divisible by 3
1 parent 48435ad commit 0ff3ac6

File tree

1 file changed

+59
-6
lines changed

1 file changed

+59
-6
lines changed

docs/src/rosalind/08-prot.md

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,39 +115,92 @@ end
115115
translate_mrna(rna, codon_table)
116116
```
117117

118+
Let's test that our function correctly deals with non-conventional mRNA strings.
119+
120+
If we change the input string to include a codon that is not present in the codon table,
121+
we should get a warning.
122+
The codon should also be translated to an amino acid "X."
123+
```julia
124+
translate_mrna("AUGNCG", codon_table)
125+
```
126+
127+
Next, let's confirm that an input mRNA strand with a length that is not divisible by 3 produces the correct warning.
128+
129+
```julia
130+
translate_mrna("AUGGC", codon_table)
131+
```
132+
133+
134+
135+
118136

119137
### BioSequences Solution
120138

121-
An alternative way to approach this problem would be to leverage an already written,
122-
established function from the BioSequences package in BioJulia.
139+
An alternative way to approach this problem would be to leverage
140+
an established function from the BioSequences package in BioJulia.
123141

124142
```julia
125143
using BioSequences
126144

127-
rna = "AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"
128-
129145
translate(rna"AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA")
130146

131147
```
132148

133149
This function is straightforward to use,
134150
especially in the case where the input mRNA has no ambiguous codons
135151
and is divisible by 3.
136-
However, there are also additional parameters available for handling other types of strings.
152+
However, there are also additional parameters available for handling other types of strings.
137153

138154
For instance, the function defaults to using the standard genetic code.
139155
However, if a user wishes to use another codon chart
140156
(for example, yeast or invertebrate),
141157
there are others available on [BioSequences.jl](https://github.com/BioJulia/BioSequences.jl/blob/b626dbcaad76217b248449e6aa2cc1650e95660c/src/geneticcode.jl#L130) to choose from.
142158

159+
160+
For example, we can translate the same input mRNA string.
161+
using the vertebrate mitochondrial genetic code!
162+
163+
```julia
164+
translate(rna"AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA", code=BioSequences.vertebrate_mitochondrial_genetic_code)
165+
166+
```
167+
143168
By default, `allow_ambiguous_codons` is `true`.
144169
If a user gives the function a mRNA string with ambiguous codons that may not be found in the standard genetic code,
145170
these codons will be translated to the narrowest amino acid which covers all
146171
non-ambiguous codons encompassed by the ambiguous codon.
147172
If this option is turned off,
148173
ambiguous codons will cause an error.
149174

175+
For example, the input mRNA string below includes the nucleotides `NCG`,
176+
which is an ambiguous codon.
177+
This could potentially code for `ACG` (Threonine),
178+
`CCG` (Proline), `UCG` (Serine), `GCG` (Alanine),
179+
each of which would code for four different amino acids.
180+
181+
`allow_ambiguous_codons` is `true` by default,
182+
so this mRNA strand is translated to `MX`.
183+
184+
```julia
185+
translate(rna"AUGNCG")
186+
```
187+
188+
However, if `allow_ambiguous_codons` is changed to `false`,
189+
an error is thrown, as no ambiguous codons are allowed in the result.
190+
191+
```julia
192+
translate(rna"AUGNCG", allow_ambiguous_codons=false)
193+
```
194+
150195
Additionally, `alternative_start` is `false` by default.
151196
If set to true, the starting amino acid will be Methionine regardless of what the first codon is.
152197

153-
Similar to our function, the BioSequences function also throws an error if the input mRNA string is not divisible by 3.
198+
```julia
199+
translate(rna"AUCGAC", alternative_start = true)
200+
```
201+
202+
Similar to our function, the BioSequences function also throws an error if the input mRNA string is not divisible by 3.
203+
204+
```julia
205+
translate(rna"AUGGA")
206+
```

0 commit comments

Comments
 (0)