2. Transcribing DNA into RNA

时间:2023-02-09 14:45:19

Problem

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

# -*- coding: utf-8 -*-
"""
Created on Thu Dec 08 20:33:16 2016

@author: hyl
"""
### 2. Transcribing DNA into RNA ###
import re
d = {'A':0,'T':0,'G':0,'C':0}
f=  open('C:\\Users\\hyl\\Desktop\\rosalind_rna.txt')
#print f.readlines()
dna = ''
for line in f.readlines():
    #line = line.rstrip()
    dna += line
rnaseq = re.sub("T","U",dna,count =0)
print rnaseq