Skip to content

Commit

Permalink
Fix MAGMA executable links
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed May 17, 2024
1 parent b4b9192 commit 7b779c1
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 23 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: MAGMA.Celltyping
Type: Package
Title: Find Causal Cell-Types Underlying Complex Trait Genetics
Version: 2.0.11
Version: 2.0.12
Authors@R:
c(person(given = "Brian",
family = "Schilder",
Expand Down Expand Up @@ -73,6 +73,6 @@ Suggests:
SystemRequirements: A system installation of
[MAGMA](https://ctg.cncr.nl/software/magma) is required
but can be installed automatically by this package.
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Encoding: UTF-8
Config/testthat/edition: 3
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# MAGMA.Celltyping 2.0.12

## Bug fixes

* Update URLs for getting MAGMA executables.

# MAGMA.Celltyping 2.0.11

## New features
Expand Down
1 change: 1 addition & 0 deletions R/format_sumstats_for_magma.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ format_sumstats_for_magma <- function(path) {
mungesumstats_deprecation_msg()
}


format.sumstats.for.magma <- function(path){
format_sumstats_for_magma(path)
}
1 change: 1 addition & 0 deletions R/get_genome_ref.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ get_genome_ref <- function(genome_ref_path = NULL,
timeout = 60 * 5,
verbose = TRUE) {
#### population ####
dir.create(storage_dir,showWarnings = FALSE, recursive = TRUE)
population <- tolower(population[1])
method <- tolower(method[1])
pop_opts <- c("eur", "afr", "amr", "eas", "sas")
Expand Down
4 changes: 3 additions & 1 deletion R/list_remote_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#' @importFrom XML htmlParse xpathSApply free
list_remote_files <- function(URL,
pattern = "*.zip") {
# URL <- "https://ctg.cncr.nl/software/MAGMA/prog/"

# doc <- rvest::read_html("https://vu.data.surfsara.nl/index.php/s/8qDPUbOTrZ9lW2b/")
# rvest::html_elements(doc,"a")
doc <- XML::htmlParse(readLines(URL), asText = TRUE)
links <- XML::xpathSApply(doc, "//a/@href")
XML::free(doc)
Expand Down
6 changes: 3 additions & 3 deletions R/magma_download_binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#' @keywords internal
magma_download_binary <- function(magma_url,
dest_dir = find_install_dir(),
destfile = basename(magma_url),
verbose = TRUE) {
#### Download the appropriate executable ####
destfile <- file.path(dest_dir, basename(magma_url))
destfile <- fix_path(destfile)
#### Download the appropriate executable ####
destfile <- fix_path(file.path(dest_dir,destfile))
messager("Downloading MAGMA executable ==>",dest_dir, v = verbose)
# Create the decompressed file name in advance
destpath <- gsub("\\.zip$", "", destfile)
Expand Down
6 changes: 4 additions & 2 deletions R/magma_install.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
#' @export
#' @importFrom utils unzip
#' @examples
#' magma <- MAGMA.Celltyping::magma_install()
#' magma <- magma_install()
magma_install <- function(dest_dir = find_install_dir(),
desired_version = "latest",
upgrade = FALSE,
verbose = TRUE) {
#### Standardise desired_version ####
if(is.null(desired_version) || length(desired_version)==0) {
if(is.null(desired_version) ||
length(desired_version)==0) {
desired_version <- "latest"
}
desired_version <- tolower(desired_version)[1]
Expand Down Expand Up @@ -67,6 +68,7 @@ magma_install <- function(dest_dir = find_install_dir(),
destpath <- magma_download_binary(
magma_url = magma_url,
dest_dir = dest_dir,
destfile = paste0(names(magma_url),".zip"),
verbose = verbose
)
dest_magma <- magma_find_executable(destpath = destpath)
Expand Down
11 changes: 10 additions & 1 deletion R/magma_links.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ magma_links <- function(latest_only = TRUE,
use_local = TRUE,
return_table = FALSE,
verbose = TRUE) {
latest <- NULL;
latest <- link <- NULL;
#### Avoid issues with subset when colnames same as variable names ####
OS <- os;
VERSION <- if(is.null(version)) {
Expand All @@ -34,6 +34,15 @@ magma_links <- function(latest_only = TRUE,
magma_links_gather()
}, error = function(e) MAGMA.Celltyping::magma_links_stored)
}
#### Fix URLs ####
## Need to update this bit manually...
meta[version=="v1.10" & os=="Linux",link:="https://vu.data.surfsara.nl/index.php/s/zkKbNeNOZAhFXZB/download"]
meta[version=="v1.10" & os=="Mac",link:="https://vu.data.surfsara.nl/index.php/s/1M1d9vHtVidEwvU/download"]
meta[version=="v1.10" & os=="Windows",link:="https://vu.data.surfsara.nl/index.php/s/TOH4SuvczAKE29d/download"]
meta[version=="v1.10" & os=="source",link:="https://vu.data.surfsara.nl/index.php/s/1OOi7bxLWef0GwY/download"]
## Can substitute the rest
meta[,link:=gsub("https://ctg.cncr.nl/software/MAGMA/prog//|https://ctg.cncr.nl/software/MAGMA/prog/archive//",
"https://vu.data.surfsara.nl/index.php/s/8qDPUbOTrZ9lW2b/download?path=%2F&files=",link)]
#### Filter by OS ####
if (!is.null(OS)) {
meta <- subset(meta, os==OS)
Expand Down
8 changes: 7 additions & 1 deletion R/magma_links_versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ magma_links_versions <- function(links,
filter_v = TRUE,
verbose = TRUE){
if(!is.character(links)) return(NULL)
versions <- stringr::str_split(links, "_", simplify = TRUE)[,2]
versions <- sapply(seq_len(length(links)),function(i){
if(endsWith(links[[i]],".zip")){
strsplit(links[[i]],"_")[[1]][2]
} else{
strsplit(names(links)[i],"_")[[1]][2]
}
})
versions <- gsub(".zip","",versions)
if(unique_only){
versions <- unique(versions)
Expand Down
7 changes: 6 additions & 1 deletion man/magma_download_binary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/magma_install.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions tests/testthat/test-magma_links.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
test_that("magma_links works", {

if(!is_32bit()){
to_numeric <- function(x){
as.numeric(
gsub(
paste( c(letters,".zip"), collapse = "|" ),"",
stringr::str_split(basename(x),"_")[[1]][2]
)
)
to_version <- function(x){
package_version(
gsub("v","",MAGMA.Celltyping:::magma_links_versions(x))
)
}

#### Mac ####
magma_mac <- MAGMA.Celltyping:::magma_links(latest_only = TRUE,
magma_mac <-MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Mac",
verbose = FALSE)
testthat::expect_gte(to_numeric(magma_mac), 1.1)
testthat::expect_true(to_version(magma_mac)>=1.1)

#### Windows ####
magma_win <- MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Windows")
testthat::expect_gte(to_numeric(magma_win), 1.1)
testthat::expect_true(to_version(magma_win)>=1.1)

#### Linux ####
magma_linux <- MAGMA.Celltyping:::magma_links(latest_only = TRUE,
os = "Linux")
testthat::expect_gte(to_numeric(magma_linux), 1.1)
testthat::expect_true(to_version(magma_linux)>=1.1)

#### All ####
meta <- MAGMA.Celltyping:::magma_links(latest_only = FALSE,
Expand Down

0 comments on commit 7b779c1

Please sign in to comment.