solveUserSEW             package:IRanges             R Documentation

_T_h_e _S_E_W (_S_t_a_r_t/_E_n_d/_W_i_d_t_h) _i_n_t_e_r_f_a_c_e

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

     'solveUserSEW' is a utility function that solves a set of
     user-supplied start/end/width values.

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

       solveUserSEW(refwidths, start=NA, end=NA, width=NA,
                    translate.nonpositive.coord=TRUE,
                    allow.nonnarrowing=FALSE)

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

refwidths: Vector of non-negative integers containing the reference
          widths. 

start, end, width: Vectors of integers, eventually with NAs, containing
          the set of user-supplied start/end/width values. 

translate.nonpositive.coord, allow.nonnarrowing: 'TRUE' or 'FALSE'. 

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

     'start', 'end' and 'width' must have the same number of elements
     as, or less elements than, 'refwidths'. In the latter case, they
     are expanded cyclically to the length of 'refwidths' (provided
     none are of zero length). After this expansion, each row in the
     3-column matrix obtained by binding those 3 vectors together must
     contain at least one NA (otherwise an error is returned).

     Then each row is "solved" i.e. the 2 following transformations are
     performed ('i' is the indice of the row): (1) if
     'translate.nonpositive.coord' is TRUE then a non-positive value of
     'start[i]' or 'end[i]' is considered to be a '-refwidths[i]'-based
     coordinate so 'refwidths[i]+1' is added to it to make it 1-based;
     (2) the NAs in the row are treated as unknowns which values are
     deduced from the known values in the row and from 'refwidths[i]'.

     The exact rules for (2) are the following. Rule (2a): if the row
     contains at least 2 NAs, then 'width[i]' must be one of them
     (otherwise an error is returned), and if 'start[i]' is one of them
     it is replaced by 1, and if 'end[i]' is one of them it is replaced
     by 'refwidths[i]', and finally 'width[i]' is replaced by 'end[i] -
     start[i] + 1'. Rule (2b): if the row contains only 1 NA, then it
     is replaced by the solution of the 'width[i] == end[i] - start[i]
     + 1' equation.

     Finally, the set of solved rows is returned as an IRanges object.

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

     An IRanges object (with the same number of elements as
     'refwidths') representing the set of solved start/end/width
     values, or an error if either (1) the set of user-supplied
     start/end/width values is invalid or (2) 'allow.nonnarrowing' is
     FALSE and the ranges represented by the solved start/end/width
     values are not narrowing the ranges represented by the
     user-supplied start/end/width values.

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

     H. Pages

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

     IRanges-class, 'narrow'

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

       refwidths <- c(5:3, 6:7)
       refwidths

       solveUserSEW(refwidths)
       solveUserSEW(refwidths, start=4)
       solveUserSEW(refwidths, end=3, width=2)
       solveUserSEW(refwidths, start=-3)
       solveUserSEW(refwidths, start=-3, width=2)
       solveUserSEW(refwidths, end=-4)

       ## The start/end/width arguments are expanded cyclically
       solveUserSEW(refwidths, start=c(3, -4, NA), end=c(-2, NA))

