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

Source Code for Module Bio.Transcribe

 1  """Code to transcribe DNA into RNA or back (OBSOLETE). 
 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 considered to be obsolete, and is likely to be deprecated 
 7  in a future release of Biopython, and later removed. 
 8  """ 
 9  import string 
10   
11  from Bio import Alphabet, Seq 
12  from Bio.Alphabet import IUPAC 
13   
14 -class Transcribe:
15 - def __init__(self, dna_alphabet, rna_alphabet):
16 self.dna_alphabet = dna_alphabet 17 self.rna_alphabet = rna_alphabet
18
19 - def transcribe(self, dna):
20 assert dna.alphabet == self.dna_alphabet, \ 21 "transcribe has the wrong DNA alphabet" 22 s = dna.data 23 return Seq.Seq(string.replace(s, "T", "U"), self.rna_alphabet)
24 - def back_transcribe(self, rna):
25 assert rna.alphabet == self.rna_alphabet, \ 26 "back transcribe has the wrong RNA alphabet" 27 s = rna.data 28 return Seq.Seq(string.replace(s, "U", "T"), self.dna_alphabet)
29 30 generic_transcriber = Transcribe(Alphabet.generic_dna, 31 Alphabet.generic_rna) 32 ambiguous_transcriber = Transcribe(IUPAC.ambiguous_dna, 33 IUPAC.ambiguous_rna) 34 unambiguous_transcriber = Transcribe(IUPAC.unambiguous_dna, 35 IUPAC.unambiguous_rna) 36