-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4a0671
commit 0f4ef95
Showing
2 changed files
with
20 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
package <- snakemake@params[["selected_package"]] | ||
# package <- snakemake@params[["selected_package"]] | ||
args <- commandArgs(TRUE) | ||
package <- args[1] | ||
|
||
# Check if the package is already available | ||
is_package_available <- require(package, character.only = TRUE) | ||
|
||
if (!isTRUE(is_package_available)) { | ||
# Ensure BiocManager is available since it will be needed regardless of the condition | ||
if (!require("BiocManager", quietly = TRUE)) { | ||
install.packages("BiocManager", repos = "http://cran.us.r-project.org") | ||
} | ||
|
||
# Condition 1: Install custom tar.gz Bsgenome package named BSgenome.T2T.CHM13.V2_1.0.0.tar.gz | ||
if (grepl("BSgenome.T2T.CHM13.V2_1.0.0.tar.gz", package, fixed = TRUE, perl = FALSE)) { | ||
print("T2T") | ||
BiocManager::install("GenomeInfoDbData", update = FALSE) | ||
install.packages(package, repos = NULL, type = "source") | ||
|
||
# Condition 2: Install standard Bsgenome packages (hg38/hg19/mm10) | ||
} else if (package %in% c("BSgenome.Hsapiens.UCSC.hg38", "BSgenome.Hsapiens.UCSC.hg19", "BSgenome.Mmusculus.UCSC.mm10")) { | ||
BiocManager::install(package, update = FALSE) | ||
|
||
# Condition 3: Install a custom package using devtools | ||
} else { | ||
# Check if devtools is installed, if not install it | ||
# Ensure devtools is installed | ||
if (!require("devtools", quietly = TRUE)) { | ||
install.packages("devtools", repos = "http://cran.us.r-project.org") | ||
} | ||
# Use devtools::install to install the package | ||
devtools::install(package, dependencies = TRUE, update = FALSE) | ||
} | ||
quit(save = "no") | ||
|
||
# Exit after installation, if desired | ||
# quit(save = "no") | ||
} |