def transcribe(self): """Transcribe DNA into RNA. DNA sequence is assumed to be the coding strand. Thymine (T) is replaced with uracil (U) in the transcribed sequence. Returns ------- RNA Transcribed sequence. See Also -------- translate translate_six_frames Notes ----- DNA sequence's metadata and positional metadata are included in the transcribed RNA sequence. Examples -------- Transcribe DNA into RNA: >>> from skbio import DNA >>> dna = DNA('TAACGTTA') >>> dna DNA -------------------------- Stats: length: 8 has gaps: False has degenerates: False has definites: True GC-content: 25.00% -------------------------- 0 TAACGTTA >>> dna.transcribe() RNA -------------------------- Stats: length: 8 has gaps: False has degenerates: False has definites: True GC-content: 25.00% -------------------------- 0 UAACGUUA """ seq = self._string.replace(b'T', b'U') # turn off validation because `seq` is guaranteed to be valid return skbio.RNA(seq, metadata=self.metadata, positional_metadata=self.positional_metadata, validate=False)
def _series_to_fasta_format(ff, data, sequence_type="DNA"): with ff.open() as f: for id_, seq in data.iteritems(): if sequence_type == "protein": sequence = skbio.Protein(seq, metadata={'id': id_}) elif sequence_type == "DNA": sequence = skbio.DNA(seq, metadata={'id': id_}) elif sequence_type == "RNA": sequence = skbio.RNA(seq, metadata={'id': id_}) else: raise NotImplementedError( "pd.Series can only be converted to DNA or " "protein FASTA format.") skbio.io.write(sequence, format='fasta', into=f)