setRepository            package:annotate            R Documentation

_F_u_n_c_t_i_o_n_s _t_o _a_d_d _a_r_b_i_t_r_a_r_y _r_e_p_o_s_i_t_o_r_i_e_s

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

     These functions allow end users to add arbitrary repositories for
     use with the 'htmlpage' function.

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

     setRepository(repository, FUN, ..., verbose=TRUE)
     getRepositories()
     clearRepository(repository, verbose=TRUE)

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

repository: A character name for the repository.

     FUN: A function to build hyperlinks for the repository. See
          details for more information.

     ...: Allows one to pass arbitrary code to underlying functions.

 verbose: Output warning messages?

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

     These functions allow end users to add, view, and remove
     repositories for use with the 'htmlpage' function.
     'getRepositories' will output a vector of names for available
     repositories. 'clearRepository' can be used to remove a repository
     if so desired. 'setRepository' can be used to add a repository.
     See the examples section for the format of the FUN argument.

     Once a new repository has been set, the 'htmlpage' function can be
     called using the name of the new repository as a value in the
     repository argument (e.g., htmlpage(<other args>, repository =
     list("newrepositoryname"))

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

     Martin Morgan <mtmorgan@fhcrc.org>

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

     ## A simple fake URI
     repofun <- function(ids, ...)
     paste("http://www.afakeuri.com/", ids, sep = "")

     setRepository("simple", repofun)

     ## More complicated, we want to make sure that
     ## NAs get converted to empty cells

     repofun <- function(ids, ...){
     bIDs <- which(is.na(ids))
     out <- paste("http://www.afakeuri.com/", ids, sep = "")
     out[bIDs] <- "&nbsp;"
     out
     }

     setRepository("complex", repofun)

     ## More complicated URI where we need to pass more information
     ## An example is Ensembl, which requires a species as part of the URI
     ## Since htmlpage() has an '...' argument, we can pass arbitrary
     ## arguments to this function that will be passed down to our
     ## repfun. Here we assume the argument species="Homo_sapiens" has been
     ## included in the call to htmlpage().

     repofun <- function(ids, ...){
     if(!is.null(list(...)$species))
           species <- list(...)$species
       else
           stop("To make links for Ensembl, you need to pass a 'species' argument.",
                call. = FALSE)
     out <- paste("http://www.ensembl.org/", species, "/Search/Summary?species=",
                   species, ";idx=;q=", ids, sep = "")
     out
     }

     setRepository("species_arg", repofun)

