-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranscribe.py
17 lines (16 loc) · 1.49 KB
/
transcribe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#translating DNA to RNA, first will use nonbiopython method
#Then will try a biopython method, so to do DNA to RNA we replace T with U
#we can use the string.replace function
#syntax: str.replace(old, new [, count])
#try with python first:
from Bio.Seq import Seq
def convertDNAtoRNA(s):
#takes as input a string s and outputs a string s', where s' is the string with u instead of t
s1= s.replace("T", "U")
return s1
#biopython method
my_dna= Seq("TGAGTCCTCGAGAATCAGTCTGTTGGGTAGGGCAGATTGTTGAAGCGACTATCTGACGTGCACCATTCTGTTGTCTGTTAAACAAAGATAGGGCCGGCCCATGCCCGAAAGAAGTATCATGGCAAGCACTTTTCAGAGCCCTTGAACAATCAGGATCTTCAGAGATCTGGGTTAAGTGGAGAGTCAAAATTCCCACATTCCAATTTGGCTGCAGTTCTACCGTAATCACAGGTAGCTATTTAACCGCATCGATGCACTACAGCGTTCTCAAGCCACGGCCTCCCGCAACTCCGCAGGTGCCCGTAGACTACCGCTTTTGTAGTGTTGCCAAAGCATGAGGGTCGGCGCCCATGGGTGAGCACGCGCTCGACCATAGTCGTGACCCCTAATGCGACCCCTCCCGGGATGGCGCCCATTCAGCATTAAACATGTACATATTCTCAGGGTAGGATAGGTGCGGTGTAGGATGAAGTGTGGTAGAACTCATAGACCAGCCGTCCATTACGTACTTAACCCGTGGGGGAAATAAACGTGGCGGCTCAATCAAGTTACTCAACTACGAGTGCATTCGTGCATCGATTCGGTAGGGACTTTACCTGAGACCCCGCTTGTCCAGTCCATGTGTCTCTGGTGTGGTCTGCAGCCGCGATTCATCGATCATTTGAGACCTCGCCGAAACGTAGGGTGGCGTGTCGCTGGCCCCGAGCGGGCCCCCAGCGGAGGCATCGACTTCGAGGCCCCCTGGAGCCATACGCACGGGCATCAGCATGTCTCAGTAGCAAACCACGAATTGCTGGGCGCCGGTGCGGTATTCAAAACCATTTGCTACACTGCAAGGCTCGACAGTATGTGCGGTCTAGAGAAATTCCGCTATAATGAACGGTGTAAAAAGATCACGGGGGCCATCTTTCTCTTCCGCCTATGCAACGGG")
#convert from DNA to RNA-> transcribe method
#can also convert be backtranscribe
my_rna= my_dna.transcribe()
print(my_rna)