Created
May 12, 2019 06:09
-
-
Save HelioNeves/76f3f1ebe7f4cb0e401f9a1253b1c858 to your computer and use it in GitHub Desktop.
Transcribing DNA in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Reading the line from file and putting in a content string | |
line = open('rosalind_rna.txt', 'r').readline() | |
'''METHOD 1 Iteration | |
Iterating across the input string, character by character | |
and as strings are immutable, we made a new one | |
''' | |
input_iteration = str() | |
for i in range(len(line)): | |
if line[i] == 'T': | |
input_iteration += 'U' | |
else: | |
input_iteration += line[i] | |
'''METHOD 2 Replace | |
Using the python's inbuilt method replace() | |
''' | |
input_replace = line.replace('T', 'U') | |
#If the two strings are equal, then print | |
if input_iteration == input_replace: | |
print(input_iteration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment