查看原文
其他

Y叔 2018-06-01

Problem

An RNA string is a string formed from the alphabet containing ‘A’, ‘C’, ‘G’, and ‘U’.

Given a DNA string t corresponding to a coding strand, its transcribed RNA string u is formed by replacing all occurrences of ‘T’ in t with ‘U’ in u.

Given: A DNA string t having length at most 1000 nt.

Return: The transcribed RNA string of t.

Sample Dataset

GATGGAACTTGACTACGTAAATT

Sample Output

GAUGGAACUUGACUACGUAAAUU

Solution

这道题是翻译,只要把T替换成U就可以了。和上一道题《s01 - Counting DNA Nucleotides》差不多难度。

C version

#include <stdio.h>

int main() {  FILE *INFILE;  INFILE = fopen("DATA/rosalind_rna.txt", "rt");
 char nt;  
 while( (nt = fgetc(INFILE)) != EOF) {  
   if (nt == 'T') {      nt = 'U';    }    printf("%c", nt);  }  
 return 0; }

Python version

FILE=open("DATA/rosalind_rna.txt", "r") dna=FILE.read() FILE.close() rna = dna.replace('T', 'U') print(rna)

    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存