chartr              package:Biostrings              R Documentation

_T_r_a_n_s_l_a_t_i_n_g _l_e_t_t_e_r_s _o_f _a _s_e_q_u_e_n_c_e

_D_e_s_c_r_i_p_t_i_o_n:

     Translate letters of a sequence.

_U_s_a_g_e:

       chartr(old, new, x)

_A_r_g_u_m_e_n_t_s:

     old: A character string specifying the characters to be
          translated. 

     new: A character string specifying the translations. 

       x: The sequence or set of sequences to translate. If 'x' is an
          XString, XStringSet, XStringViews or MaskedXString object,
          then the appropriate 'chartr' method is called, otherwise the
          standard 'chartr' R function is called. 

_D_e_t_a_i_l_s:

     See '?chartr' for the details.

     Note that, unlike the standard 'chartr' R function, the methods
     for XString, XStringSet, XStringViews and MaskedXString objects do
     NOT support character ranges in the specifications.

_V_a_l_u_e:

     An object of the same class and length as the original object.

_S_e_e _A_l_s_o:

     'chartr', 'replaceLetterAtLoc', XString-class, XStringSet-class,
     XStringViews-class, MaskedXString-class, 'alphabetFrequency',
     'matchPattern', 'reverseComplement'

_E_x_a_m_p_l_e_s:

       x <- BString("MiXeD cAsE 123")
       chartr("iXs", "why", x)

       ## ---------------------------------------------------------------------
       ## TRANSFORMING DNA WITH BISULFITE (AND SEARCHING IT...)
       ## ---------------------------------------------------------------------

       library(BSgenome.Celegans.UCSC.ce2)
       chrII <- Celegans[["chrII"]]
       alphabetFrequency(chrII)
       pattern <- DNAString("TGGGTGTATTTA")

       ## Transforming and searching the + strand
       plus_strand <- chartr("C", "T", chrII)
       alphabetFrequency(plus_strand)
       matchPattern(pattern, plus_strand)
       matchPattern(pattern, chrII)

       ## Transforming and searching the - strand
       minus_strand <- chartr("G", "A", chrII)
       alphabetFrequency(minus_strand)
       matchPattern(reverseComplement(pattern), minus_strand)
       matchPattern(reverseComplement(pattern), chrII)

