Home
โœ๏ธ

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 tt corresponding to a coding strand, its transcribed RNA string uu is formed by replacing all occurrences of 'T' in tt with 'U' in uu.
Given: A DNA string tt having length at most 1000 nt.
Return: The transcribed RNA string of tt.

๐Ÿ”— 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"