Package Bio :: Module Transcribe
[hide private]
[frames] | no frames]

Source Code for Module Bio.Transcribe

 1  """Code to transcribe DNA into RNA or back (DEPRECATED). 
 2   
 3  You are now encouraged to use the Seq object methods or the functions 
 4  in Bio.Seq instead. 
 5   
 6  This module is now deprecated, and will be removed in a future release of 
 7  Biopython. 
 8  """ 
 9  import warnings 
10  warnings.warn("Bio.Translate and Bio.Transcribe are deprecated, and will be "\ 
11                "removed in a future release of Biopython. Please use the "\ 
12                "functions or object methods defined in Bio.Seq instead "\ 
13                "(described in the tutorial). If you want to continue to use "\ 
14                "this code, please get in contact with the Biopython developers "\ 
15                "via the mailing lists to avoid its permanent removal from " 
16                +"Biopython.", \ 
17                DeprecationWarning) 
18   
19   
20  from Bio import Alphabet, Seq 
21  from Bio.Alphabet import IUPAC 
22   
23 -class Transcribe:
24 - def __init__(self, dna_alphabet, rna_alphabet):
25 self.dna_alphabet = dna_alphabet 26 self.rna_alphabet = rna_alphabet
27
28 - def transcribe(self, dna):
29 assert dna.alphabet == self.dna_alphabet, \ 30 "transcribe has the wrong DNA alphabet" 31 s = dna.data 32 return Seq.Seq(s.replace("T", "U"), self.rna_alphabet)
33 - def back_transcribe(self, rna):
34 assert rna.alphabet == self.rna_alphabet, \ 35 "back transcribe has the wrong RNA alphabet" 36 s = rna.data 37 return Seq.Seq(s.replace("U", "T"), self.dna_alphabet)
38 39 generic_transcriber = Transcribe(Alphabet.generic_dna, 40 Alphabet.generic_rna) 41 ambiguous_transcriber = Transcribe(IUPAC.ambiguous_dna, 42 IUPAC.ambiguous_rna) 43 unambiguous_transcriber = Transcribe(IUPAC.unambiguous_dna, 44 IUPAC.unambiguous_rna) 45