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"