]> git.donarmstrong.com Git - rsem.git/blob - EBSeq/BiocInstaller/scripts/biocLite.R
Updated samtools to 0.1.19
[rsem.git] / EBSeq / BiocInstaller / scripts / biocLite.R
1 ## Mirrors: uncomment the following and change to your favorite CRAN mirror
2 ## if you don't want to use the default (cran.fhcrc.org, Seattle, USA).
3 ## options("repos" = c(CRAN="http://cran.fhcrc.org"))
4
5 ## Mirrors: uncomment the following and change to your favorite Bioconductor
6 ## mirror, if you don't want to use the default (www.bioconductor.org,
7 ## Seattle, USA)
8 ## options("BioC_mirror" = "http://www.bioconductor.org")
9
10 local({
11     currBiocVers <- 
12         package_version(readLines("http://bioconductor.org/bioc-version",
13         warn=FALSE))
14     vers <- getRversion()
15     biocVers <- tryCatch({
16         BiocInstaller::biocVersion() # recent BiocInstaller
17     }, error=function(...) {         # no / older BiocInstaller
18         tools:::.BioC_version_associated_with_R_version
19     })
20
21     if (biocVers < currBiocVers) {
22         txt <- strwrap(sprintf("Your Bioconductor is out-of-date, upgrade
23             to version %s by following instructions at
24             http://bioconductor.org/install.", currBiocVers))
25         message(paste(txt, collapse="\n"))
26     }
27
28     if (vers > "2.13" && biocVers > "2.8") {
29
30         if (exists("biocLite", .GlobalEnv, inherits=FALSE)) {
31             txt <- strwrap("There is an outdated biocLite() function in the
32                 global environment; run 'rm(biocLite)' and try again.")
33             stop("\n", paste(txt, collapse="\n"))
34         }
35           
36         if (!suppressWarnings(require("BiocInstaller", quietly=TRUE))) {
37             a <- NULL
38             p <- file.path(Sys.getenv("HOME"), ".R", "repositories")
39             if (file.exists(p)) {
40                 a <- tools:::.read_repositories(p)
41                 if (!"BioCsoft" %in% rownames(a)) 
42                     a <- NULL
43             }
44             if (is.null(a)) {
45                 p <- file.path(R.home("etc"), "repositories")
46                 a <- tools:::.read_repositories(p)
47             }
48             if (!"package:utils" %in% search()) {
49                 url <- "http://bioconductor.org/biocLite.R"
50                 txt <- sprintf("use 'source(\"%s\")' to update 'BiocInstaller'
51                                 after 'utils' package is attached",
52                                url)
53                 message(paste(strwrap(txt), collapse="\n  "))
54             } else {
55                 ## add a conditional for Bioc releases occuring WITHIN
56                 ## a single R minor version
57                 if (vers >= "2.15" && vers < "2.16") {
58                     a["BioCsoft", "URL"] <- sub(as.character(biocVers), "2.11",
59                       a["BioCsoft", "URL"])
60                     biocVers <- numeric_version("2.11")
61                 }
62                 install.packages("BiocInstaller", repos=a["BioCsoft", "URL"])
63                 if (!suppressWarnings(require("BiocInstaller",
64                                               quietly=TRUE))) {
65                     url0 <- "http://www.bioconductor.org/packages"
66                     url <- sprintf("%s/%s/bioc",
67                                    url0, as.character(biocVers))
68                     txt0 <- "'biocLite.R' failed to install 'BiocInstaller',
69                             use 'install.packages(\"%s\", repos=\"%s\")'"
70                     txt <- sprintf(txt0, "BiocInstaller", url)
71                     message(paste(strwrap(txt), collapse="\n  "))
72                 }
73             }
74         }
75     } else {
76         source("http://bioconductor.org/getBioC.R")
77         biocLite <<-
78             function(pkgs, groupName="lite", ...)
79             {
80                 if (missing(pkgs))
81                     biocinstall(groupName=groupName, ...)
82                 else
83                     biocinstall(pkgs=pkgs, groupName=groupName, ...)
84             }
85     }
86 })