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"