Skip to content

Commit

Permalink
Merge pull request #97 from hpages/https_ucsc
Browse files Browse the repository at this point in the history
Switch from HTTP to HTTPS for requests to *.ucsc.edu
  • Loading branch information
lawremi authored Oct 20, 2023
2 parents 5a681a2 + b5d2e0f commit 1de3bf5
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rtracklayer
Title: R interface to genome annotation files and the UCSC genome browser
Version: 1.61.1
Version: 1.61.2
Author: Michael Lawrence, Vince Carey, Robert Gentleman
Depends: R (>= 3.3), methods, GenomicRanges (>= 1.37.2)
Imports: XML (>= 1.98-0), BiocGenerics (>= 0.35.3),
Expand Down
38 changes: 19 additions & 19 deletions R/readGFF.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{
if (isSingleString(filepath))
return(XVector:::open_input_files(filepath)[[1L]])
if (!is(filepath, "BiocGenerics::connection"))
if (!inherits(filepath, "connection"))
stop(wmsg("'filepath' must be a single string or a connection"))
if (!isSeekable(filepath))
if (!base::isSeekable(filepath))
stop(wmsg("connection is not seekable"))
filepath
}
Expand All @@ -22,15 +22,15 @@
readGFFPragmas <- function(filepath)
{
filexp <- .make_filexp_from_filepath(filepath)
if (is(filexp, "BiocGenerics::connection")) {
if (!isOpen(filexp)) {
open(filexp)
on.exit(close(filexp))
if (inherits(filexp, "connection")) {
if (!base::isOpen(filexp)) {
base::open(filexp)
on.exit(base::close(filexp))
}
if (seek(filexp) != 0) {
if (base::seek(filexp) != 0) {
warning(wmsg("connection is not positioned at the start ",
"of the file, rewinding it"), immediate.=TRUE)
seek(filexp, where=0)
base::seek(filexp, where=0)
}
}
.Call(read_gff_pragmas, filexp)
Expand Down Expand Up @@ -266,15 +266,15 @@ readGFF <- function(filepath, version=0, columns=NULL, tags=NULL,
{
## Check 'filepath'.
filexp <- .make_filexp_from_filepath(filepath)
if (is(filexp, "BiocGenerics::connection")) {
if (!isOpen(filexp)) {
open(filexp)
on.exit(close(filexp))
if (inherits(filexp, "connection")) {
if (!base::isOpen(filexp)) {
base::open(filexp)
on.exit(base::close(filexp))
}
if (seek(filexp) != 0) {
if (base::seek(filexp) != 0) {
warning(wmsg("connection is not positioned at the start ",
"of the file, rewinding it"), immediate.=TRUE)
seek(filexp, where=0)
base::seek(filexp, where=0)
}
}

Expand All @@ -285,8 +285,8 @@ readGFF <- function(filepath, version=0, columns=NULL, tags=NULL,
pragmas <- .Call(read_gff_pragmas, filexp)

## Rewind file.
if (is(filexp, "BiocGenerics::connection")) {
seek(filexp, where=0)
if (inherits(filexp, "connection")) {
base::seek(filexp, where=0)
} else {
XVector:::rewind_filexp(filexp)
}
Expand Down Expand Up @@ -322,8 +322,8 @@ readGFF <- function(filepath, version=0, columns=NULL, tags=NULL,
nrows <- scan_ans[[2L]]

## Rewind file.
if (is(filexp, "BiocGenerics::connection")) {
seek(filexp, where=0)
if (inherits(filexp, "connection")) {
base::seek(filexp, where=0)
} else {
XVector:::rewind_filexp(filexp)
}
Expand Down Expand Up @@ -396,7 +396,7 @@ readGFF <- function(filepath, version=0, columns=NULL, tags=NULL,
.parseSequenceRegionsAsSeqinfo <- function(lines) {
sr <- grep("##sequence-region", lines, value=TRUE)
srcon <- file()
on.exit(close(srcon))
on.exit(base::close(srcon))
writeLines(sr, srcon)
srt <- read.table(srcon, comment.char="",
colClasses=list(NULL, "character", "integer",
Expand Down
11 changes: 6 additions & 5 deletions R/ucsc.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setClass("UCSCSession",

# gets an 'hgsid' to initialize the session
setMethod("initialize", "UCSCSession",
function(.Object, url = "http://genome.ucsc.edu/cgi-bin/",
function(.Object, url = "https://genome.ucsc.edu/cgi-bin/",
user = NULL, session = NULL, force = FALSE, ...)
{
.Object@url <- url
Expand All @@ -17,7 +17,8 @@ setMethod("initialize", "UCSCSession",
gw <- httpGet(gwURL, cookiefile = tempfile(), header = TRUE,
.parse=FALSE, ...)
if (grepl("redirectTd", gw)) {
url <- sub(".*?a href=\"h([^[:space:]]+cgi-bin/).*", "h\\1", gw)
url <- sub(".*?a href=\"http([^[:space:]]+cgi-bin/).*",
"https\\1", gw)
return(initialize(.Object, url, user=user, session=session,
force=TRUE, ...))
}
Expand Down Expand Up @@ -300,7 +301,7 @@ normArgTrack <- function(name, trackids) {
setMethod("ucscTableQuery", "character",
function(x, track = NULL, range = NULL, table = NULL,
names = NULL, intersectTrack = NULL, check = TRUE, hubUrl = NULL,
genome = NULL, url = "http://genome.ucsc.edu/cgi-bin/") {
genome = NULL, url = "https://genome.ucsc.edu/cgi-bin/") {
stopifnot(isSingleString(x))
if (!is.null(intersectTrack))
stop("intersectTrack is no longer supported")
Expand Down Expand Up @@ -361,7 +362,7 @@ setReplaceMethod("hubUrl", "UCSCTableQuery", function(x, value) {

## gets the track names available from the table browser
ucscTableTracks <- function(genome) {
doc <- httpGet("http://genome-euro.ucsc.edu/cgi-bin/hgTables", c(db = genome, hgta_group = "allTracks"))
doc <- httpGet("https://genome-euro.ucsc.edu/cgi-bin/hgTables", c(db = genome, hgta_group = "allTracks"))
label_path <- "//select[@name = 'hgta_track']/option/text()"
labels <- sub("\n.*$", "", sapply(getNodeSet(doc, label_path), xmlValue))
track_path <- "//select[@name = 'hgta_track']/option/@value"
Expand Down Expand Up @@ -1485,7 +1486,7 @@ setMethod("ucscTrackModes", "ucscTracks",
ucscGenomes <- function(organism=FALSE) {
stopifnot(isTRUEorFALSE(organism))
names <- c("db", "species", "date", "name", "organism")
url <- RestUri("http://api.genome.ucsc.edu/")
url <- RestUri("https://api.genome.ucsc.edu/")
response <- read(url$list$ucscGenomes)
genomes <- response[[5]]
genomeNames <- names(genomes)
Expand Down
2 changes: 1 addition & 1 deletion inst/unitTests/test_bed.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ test_extendedBed <- function()

# the narrowPeak format represents a variety of "BED6+N" formats
# used by the ENCODE project. see
# http://genome.ucsc.edu/FAQ/FAQformat.html
# https://genome.ucsc.edu/FAQ/FAQformat.html
# "This format is used to provide called peaks of signal
# enrichment based on pooled, normalized (interpreted) data.
# It is a BED6+4 format."
Expand Down
2 changes: 1 addition & 1 deletion man/BEDFile-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export.bedGraph(object, con, ...)
\author{Michael Lawrence}

\references{
\url{http://genome.ucsc.edu/goldenPath/help/customTrack.html}
\url{https://genome.ucsc.edu/goldenPath/help/customTrack.html}
\url{http://bedtools.readthedocs.org/en/latest/content/general-usage.html}
}

Expand Down
2 changes: 1 addition & 1 deletion man/Bed15TrackLine-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
}
\references{ Official documentation:
\url{http://genomewiki.ucsc.edu/index.php/Microarray_track}. }
\url{https://genomewiki.ucsc.edu/index.php/Microarray_track}. }
\author{ Michael Lawrence }
\seealso{
\code{\link{export.bed15}} for exporting bed15 tracks.
Expand Down
2 changes: 1 addition & 1 deletion man/UCSCFile-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export.ucsc(object, con, ...)
\author{Michael Lawrence}

\references{
\url{http://genome.ucsc.edu/goldenPath/help/customTrack.html}
\url{https://genome.ucsc.edu/goldenPath/help/customTrack.html}
}

\keyword{methods}
Expand Down
2 changes: 1 addition & 1 deletion man/WIGFile-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export.wig(object, con, ...)
\author{Michael Lawrence}

\references{
\url{http://genome.ucsc.edu/goldenPath/help/wiggle.html}
\url{https://genome.ucsc.edu/goldenPath/help/wiggle.html}
}

\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/basicTrackLine-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Class \code{"\linkS4class{TrackLine}"}, directly.
}
}
\references{
\url{http://genome.ucsc.edu/goldenPath/help/customTrack.html#TRACK}
\url{https://genome.ucsc.edu/goldenPath/help/customTrack.html#TRACK}
for the official documentation. }
\author{ Michael Lawrence }

Expand Down
2 changes: 1 addition & 1 deletion man/liftOver.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ liftOver(x, chain, ...)
from the corresponding element in the input (may be one-to-many).
}
\references{
\url{http://genome.ucsc.edu/cgi-bin/hgLiftOver}
\url{https://genome.ucsc.edu/cgi-bin/hgLiftOver}
}
\examples{
\dontrun{
Expand Down
2 changes: 1 addition & 1 deletion man/ucscGenomes.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ucscGenomes(organism=FALSE)
genome.}
\details{
For populating the organism column, the web url
\url{http://genome.ucsc.edu/cgi-bin} is scraped for every assembly
\url{https://genome.ucsc.edu/cgi-bin} is scraped for every assembly
version to get the scientific name.
}
\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/ucscSession-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
\section{Objects from the Class}{
Objects can be created by calls of the form
\code{\link{browserSession}("ucsc", url =
"http://genome.ucsc.edu/cgi-bin", ...)}. The arguments in \code{...}
"https://genome.ucsc.edu/cgi-bin", ...)}. The arguments in \code{...}
correspond to libcurl options, see
\code{\link[RCurl]{getCurlHandle}}. Setting these options may be
useful e.g. for getting past a proxy.
Expand Down
2 changes: 1 addition & 1 deletion man/ucscTrackLine-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
}
\references{
\url{http://genome.ucsc.edu/goldenPath/help/customTrack.html#TRACK}
\url{https://genome.ucsc.edu/goldenPath/help/customTrack.html#TRACK}
for the official documentation. }
\author{ Michael Lawrence }

Expand Down
2 changes: 1 addition & 1 deletion man/wigTrackLine-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}
}
\references{ Official documentation:
\url{http://genome.ucsc.edu/goldenPath/help/wiggle.html}. }
\url{https://genome.ucsc.edu/goldenPath/help/wiggle.html}. }
\author{ Michael Lawrence }
\seealso{
\code{\link{export.wig}}, \code{\link{export.bedGraph}} for exporting
Expand Down
6 changes: 3 additions & 3 deletions vignettes/rtracklayer.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ region of the motif.
\Rclass{rtracklayer} can be used to download annotation tracks from
the UCSC table browser, thus providing a convenient programmatic
alternative to the web interface available at
\url{http://genome.ucsc.edu/cgi-bin/hgTables}.
\url{https://genome.ucsc.edu/cgi-bin/hgTables}.

\textbf{Note} that not all tables are output in parseable form, and
that \textbf{UCSC will truncate responses} if they exceed certain
Expand All @@ -668,7 +668,7 @@ tbl.rmsk <- getTable(
There are several important points to understand about this example:
\begin{enumerate}
\item The \Rcode{ucscTableQuery} used above is a proxy for, and provides communication with,
the remote UCSC table browser (see \url{http://genome.ucsc.edu/cgi-bin/hgTables}).
the remote UCSC table browser (see \url{https://genome.ucsc.edu/cgi-bin/hgTables}).
\item You must know the name of the track and table (or sub-track) that you want. The
way to do this is explained in detail below, in section 5.3.
\item If the track contains multiple tables (which is the case for
Expand Down Expand Up @@ -709,7 +709,7 @@ tbl.k562.dgf.hg19 <- getTable(ucscTableQuery (mySession, track=track.name,

As the examples above demonstrate, you must know the exact UCSC-style name for
the track and table you wish to download. You may browse these interactively at
\url{http://genome.ucsc.edu/cgi-bin/hgTables?org=Human&db=hg19} or
\url{https://genome.ucsc.edu/cgi-bin/hgTables?org=Human&db=hg19} or
programmatically, as we demonstrate here.

<<trackAndTableNameDiscovery, eval=FALSE>>=
Expand Down

0 comments on commit 1de3bf5

Please sign in to comment.