XStringViews-constructors     package:Biostrings     R Documentation

_B_a_s_i_c _f_u_n_c_t_i_o_n_s _f_o_r _c_r_e_a_t_i_n_g _o_r _m_o_d_i_f_y_i_n_g _X_S_t_r_i_n_g_V_i_e_w_s _o_b_j_e_c_t_s

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

     A set of basic functions for creating or modifying XStringViews
     objects.

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

       views(subject, start=NA, end=NA)
       adjacentViews(subject, width, gapwidth=0)
       XStringViews(x, subjectClass, collapse="")
       trim(x, use.names=TRUE)
       subviews(x, start=NA, end=NA, width=NA, use.names=TRUE)

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

 subject: An XString object or a single string. 

   start: An integer vector containing the start positions of the
          views. 

     end: An integer vector containing the end positions of the views. 

   width: An integer vector containing the widths of the views. 

gapwidth: An integer vector containing the widths of the gaps between
          the views. 

       x: An XString object or a character vector for 'XStringViews'.
          An XStringViews object for 'trim' and 'subviews'. 

subjectClass: The class to be given to the subject of the XStringViews
          object created and returned by the function. Must be the name
          of one of the direct XString subtypes i.e. '"BString"',
          '"DNAString"', '"RNAString"' or '"AAString"'. 

collapse: An optional character string to be inserted between the views
          of the XStringViews object created and returned by the
          function. 

use.names: [TODO] 

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

     The 'views' function returns an XStringViews object containing
     views on 'subject' with start and end positions given in the
     'start' and 'end' vectors.

     The 'adjacentViews' function returns an XStringViews object
     containing views on 'subject' with widths given in the 'width'
     vector and separated by gaps of width 'gapwidth'. The first view
     starts at position 1.

     The 'XStringViews' constructor will try to create an XStringViews
     object from the value passed to its 'x' argument. If 'x' itself is
     an XStringViews object, the returned object is obtained by
     coercing its subject to the class specified by 'subjectClass'. If
     'x' is an XString object, the returned object is made of a single
     view that starts at the first letter and ends at the last letter
     of 'x' (in addition 'x' itself is coerced to the class specified
     by 'subjectClass' when specified). If 'x' is a character vector,
     the returned object has one view per character string in 'x' (and
     its subject is an instance of the class specified by
     'subjectClass').

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

     All these functions return an XStringViews object 'y' with the
     following number of views ('length(y)'): 'max(length(start),
     length(end)' for the 'views' function and 'length(width)' for the
     'adjacentViews' function. For the 'XStringViews' constructor,
     'length(y)' is '1' when 'x' is an XString object and 'length(x)'
     otherwise.

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

     XStringViews-class, XString-class, 'gaps'

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

       ## 'start' and 'end' are recycled
       views("abcdefghij", 2:1, 4)
       views("abcdefghij", 5:7, )
       views("abcdefghij", , 5:7)

       ## Views can be "out of limits"
       views("abcdefghij", 2:0, 4)

       ## Views on a DNAString object
       v12 <- views(DNAString("TAATAATG"), -2:9, 0:11)

       ## Creating adjacent views
       v3 <- adjacentViews("abcdefghij", 4:2, gapwidth=1)

       XStringViews(v12, subjectClass="RNAString")
       XStringViews(AAString("MARKSLEMSIR*"))
       XStringViews("abcdefghij", subjectClass="BString")

       ## Applying gaps() to an XStringViews object
       v2 <- views("abCDefgHIJK", start=c(8, 3), end=c(14, 4))
       gaps(v2)

