Skip to content

Commit

Permalink
Some tweaks to UCSC.api.url() and its man page
Browse files Browse the repository at this point in the history
  • Loading branch information
hpages committed Apr 17, 2024
1 parent aa8b2e9 commit ec64714
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ biocViews: Infrastructure, GenomeAssembly, Annotation, GenomeAnnotation,
DataImport
URL: https://bioconductor.org/packages/UCSC.utils
BugReports: https://github.com/Bioconductor/UCSC.utils/issues
Version: 0.99.6
Version: 0.99.7
License: Artistic-2.0
Encoding: UTF-8
Authors@R: person("Hervé", "Pagès", role=c("aut", "cre"),
Expand Down
14 changes: 7 additions & 7 deletions R/UCSC.api.url.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
###


UCSC.api.url <- function(new_url=NULL)
UCSC.api.url <- function(url=NULL)
{
ans <- getOption("UCSC.api.url")
if (is.null(new_url))
if (is.null(url))
return(ans)
if (!(isSingleString(new_url) && nzchar(new_url)))
stop(wmsg("'new_url' must be a single (non-empty) string"))
if (!startsWith(tolower(new_url), "http"))
stop(wmsg("'new_url' must start with \"http\""))
options(UCSC.api.url=new_url)
if (!(isSingleString(url) && nzchar(url)))
stop(wmsg("'url' must be a single (non-empty) string"))
if (!startsWith(tolower(url), "http"))
stop(wmsg("'url' must start with \"http\""))
options(UCSC.api.url=url)
invisible(ans) # return old URL invisibly
}

41 changes: 24 additions & 17 deletions man/UCSC.api.url.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,41 @@
\title{Get or set the default UCSC API URL}

\description{
Get or set the default UCSC API URL.
Convenience helper for getting or setting global option \code{UCSC.api.url}.
}

\usage{
UCSC.api.url(new_url=NULL)
UCSC.api.url(url=NULL)
}

\arguments{
\item{new_url}{
\item{url}{
Alternative UCSC API URL to use by default.
}
}

\details{
\code{UCSC.api.url()} is just a convenience wrapper for
\code{getOption("UCSC.api.url")}.
Various functions in the \pkg{UCSC.utils} package query the UCSC REST API.
This is the case for example for \code{\link{list_UCSC_genomes}},
\code{\link{get_UCSC_chrom_sizes}}, \code{\link{list_UCSC_tracks}}
and others.

Global option \code{UCSC.api.url} controls the UCSC API URL
that these functions use y default. The option is set to
\code{"https://api.genome.ucsc.edu"} at package startup.

To change the default UCSC API URL, call \code{UCSC.api.url(new_url)}
where \code{new_url} is a single string containing the alternative URL.
Note that this is just a convenience wrapper for
\code{options(UCSC.api.url=new_url)}.
\code{UCSC.api.url()} and \code{UCSC.api.url(url)} are provided
as convenient ways of doing \code{getOption("UCSC.api.url")}
and \code{options(UCSC.api.url=url)}, respectively.
}

\value{
When called with no argument, \code{UCSC.api.url()} returns the URL of
the UCSC API that is currently used by default.
When called with no argument, \code{UCSC.api.url()} returns
\code{getOption("UCSC.api.url")}.

When passed a new URL, \code{UCSC.api.url(new_url)} returns the URL of
the UCSC API that was \emph{previously} used by default. Note that the
URL is returned invisibly.
When passed an URL, \code{UCSC.api.url(url)} returns the \emph{old} URL,
that is, the UCSC API URL that was previously used by default. Note
that the \emph{old} URL is returned invisibly.
}

\seealso{
Expand All @@ -47,14 +52,16 @@ UCSC.api.url(new_url=NULL)
}

\examples{
UCSC.api.url() # current default UCSC API URL
UCSC.api.url() # current default value of the UCSC API URL
get_UCSC_chrom_sizes("ce11", recache=TRUE)

## Temporarily use the mirror in Asia:
old_url <- UCSC.api.url("https://genome-asia.ucsc.edu/cgi-bin/hubApi")
UCSC.api.url() # new default value of the UCSC API URL
\donttest{
get_UCSC_chrom_sizes("ce11", recache=TRUE)

## Restore old URL:
}
## Restore old default value:
UCSC.api.url(old_url)
}

Expand Down
4 changes: 2 additions & 2 deletions vignettes/UCSC.utils.Rmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "The **UCSC.utils** package"
title: "The _UCSC.utils_ package"
author:
- name: Hervé Pagès
affiliation: Fred Hutchinson Cancer Research Center, Seattle, WA
date: "Compiled `r doc_date()`; Modified 8 April 2024"
date: "Compiled `r doc_date()`; Modified 16 April 2024"
package: UCSC.utils
vignette: |
%\VignetteIndexEntry{The UCSC.utils package}
Expand Down

0 comments on commit ec64714

Please sign in to comment.