Views-class             package:IRanges             R Documentation

_V_i_e_w_s _o_b_j_e_c_t_s

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

     The Views virtual class is a general container for storing a set
     of views on an arbitrary Sequence object, called the "subject".

     Its primary purpose is to introduce concepts and provide some
     facilities that can be shared by the concrete classes that derive
     from it.

     Some direct subclasses of the Views class are: XIntegerViews,
     RleViews, XStringViews (defined in the Biostrings package), etc...

_C_o_n_s_t_r_u_c_t_o_r:


      'Views(subject, start=NULL, end=NULL, width=NULL, names=NULL)':
          This constructor is a generic function with dispatch on
          argument 'subject'. Specific methods must be defined for the
          subclasses of the Views class. For example a method for
          XString subjects is defined that returns an XStringViews
          object. There is no default method.

          The treatment of the 'start', 'end' and 'width' arguments is
          the same as with the 'IRanges' constructor, except that, in
          addition, 'Views' allows 'start' to be an IRanges object.
          This ensures that 'Views(subject, IRanges(mystarts, myends,
          mywidths, mynames))' and 'Views(subject, mystarts, myends,
          mywidths, mynames)' are equivalent (except when 'mystarts' is
          itself an IRanges object).


_A_c_c_e_s_s_o_r-_l_i_k_e _m_e_t_h_o_d_s:

     All the accessor-like methods defined for 'IRanges' objects work
     on Views objects. In addition, the following accessors are defined
     for Views objects:


      'subject(x)': Return the subject of the views.


_S_u_b_s_e_t_t_i_n_g _a_n_d _a_p_p_e_n_d_i_n_g:

     The '"["' and 'c' methods defined for 'IRanges' objects work on
     Views objects and return a Views object. In addition, the '"[["'
     operator is defined for Views objects:


      'x[[i]]': Extracts the view selected by 'i' as an object of the
          same class as 'subject(x)'. Subscript 'i' can be a single
          integer or a character string. The result is the subsequence
          of 'subject(x)' defined by 'subseq(subject(x),
          start=start(x)[i], end=end(x)[i])' or an error if the view is
          "out of limits" (i.e. 'start(x)[i] < 1' or 'end(x)[i] >
          length(subject(x))').


_O_t_h_e_r _m_e_t_h_o_d_s:


      'restrict(x, start, end, keep.all.ranges=FALSE, use.names=TRUE)':
          'start' and 'end' must be single integers specifying the
          restriction window. 'restrict' will drop the views that don't
          overlap with the restriction window and drop the parts of the
          remaining views that are outside the window.

      'trim(x, use.names=TRUE)': [TODO]

      'narrow(x, start=NA, end=NA, width=NA, use.names=TRUE)': [TODO]

      'subviews(x, start=NA, end=NA, width=NA, use.names=TRUE)': [TODO]

      'gaps(x, start=NA, end=NA)': 'start' and 'end' can be single
          integers or NAs. The gap extraction will be restricted to the
          window specified by 'start' and 'end'. 'start=NA' and
          'end=NA' are interpreted as 'start=1' and
          'end=length(subject(x))', respectively, so, if 'start' and
          'end' are not specified, then gaps are extracted with respect
          to the entire subject.

      'successiveViews(subject, width, gapwidth=0, from=1)': Equivalent
          to 'Views(subject, successiveIRanges(width, gapwidth,
          from))'. See '?successiveIRanges' for a description of the
          'width', 'gapwidth' and 'from' arguments.


_A_u_t_h_o_r(_s):

     H. Pages

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

     IRanges-class, ListLike-class, IRanges-utils, Sequence, XSequence.

     Some direct subclasses of the Views class: XIntegerViews-class,
     RleViews-class, XStringViews-class.

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

       showClass("Views")  # shows (some of) the known subclasses

       ## Create a set of 4 views on an XInteger subject of length 10:
       subject <- XInteger(10, 3:-6)
       v1 <- Views(subject, start=4:1, end=4:7)

       ## Extract the 2nd view:
       v1[[2]]

       ## Some views can be "out of limits"
       v2 <- Views(subject, start=4:-1, end=6)
       trim(v2)
       subviews(v2, end=-2)

       ## gaps() 
       v3 <- Views(subject, start=c(8, 3), end=c(14, 4))
       gaps(v3)

       ## Views on a big XInteger subject:
       subject <- XInteger(99999, sample(99, 99999, replace=TRUE) - 50)
       v4 <- Views(subject, start=1:99*1000, end=1:99*1001)
       v4
       v4[-1]
       v4[[5]]

       ## 31 adjacent views:
       successiveViews(subject, 40:10)

