Rosalind #2: Transcribing DNA into RNA
AnĀ RNA stringĀ is aĀ stringĀ formed from theĀ alphabetĀ containing 'A', 'C', 'G', and 'U'.
Given aĀ DNA stringĀ Ā corresponding to a coding strand, its transcribedĀ RNA stringĀ Ā is formed by replacing all occurrences of 'T' inĀ Ā with 'U' inĀ .Return:Ā The transcribed RNA string ofĀ .
š Sample Dataset
GATGGAACTTGACTACGTAAATT
š Sample Output
GAUGGAACUUGACUACGUAAAUU
š Solution
Using Blocks, we can apply an anonymous function to a value, where š© is the argument to the function.
{ š© + 5 } 2
7
Blocks also support āCase headers,ā allowing us to write if-statements.
{
5: "Five!" ;
š© + 2
} 5
"Five!"
{
5: "Five!" ;
š© + 2
} 3
5
We can replace the character āTā with the character āUā.
{ 'T' : 'U' } 'T'
'U'
But we need a default case.
{'T':'U'} 'A'
Error: No header matched argument
{'T':'U';š©} 'A'
'A'
We can apply our function to a list (or a string of characters) with š½ĀØ š©,Ā šØ š½ĀØ š©: Each.
{'T':'U';š©}ĀØ "LETS GO"
"LEUS GO"
We can replace Tās in our DNA string with Uās.
Rosalind2 ā {'T':'U';š©}ĀØ
(function block)ĀØ
Rosalind2 "GATGGAACTTGACTACGTAAATT"
"GAUGGAACUUGACUACGUAAAUU"