
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"