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