forked from Shivi91/Rosalind-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path002_RNA.py
32 lines (24 loc) · 772 Bytes
/
002_RNA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Transcribing DNA into RNA
Rosalind ID: RNA
Rosalind #: 002
URL: http://rosalind.info/problems/rna/
'''
def dna_to_rna(dna):
'''Translates the given DNA sequence to an RNA sequence.'''
return dna.replace('T', 'U')
def main():
'''Main call. Parses, runs, and saves problem specific data.'''
# Read the input data.
with open('data/rosalind_rna.txt') as input_data:
dna = input_data.read().strip()
# Translate the DNA sequence to an RNA sequence.
rna = dna_to_rna(dna)
# Print and save the answer.
print rna
with open('output/002_RNA.txt', 'w') as output_data:
output_data.write(rna)
if __name__ == '__main__':
main()