From 7b779c12fcc5bb75e3150ede8ddc4a31b0ba0c8c Mon Sep 17 00:00:00 2001 From: "Brian M. Schilder" <34280215+bschilder@users.noreply.github.com> Date: Fri, 17 May 2024 17:58:35 +0100 Subject: [PATCH] Fix MAGMA executable links --- .DS_Store | Bin 8196 -> 8196 bytes DESCRIPTION | 4 ++-- NEWS.md | 6 ++++++ R/format_sumstats_for_magma.r | 1 + R/get_genome_ref.R | 1 + R/list_remote_files.R | 4 +++- R/magma_download_binary.R | 6 +++--- R/magma_install.R | 6 ++++-- R/magma_links.R | 11 ++++++++++- R/magma_links_versions.R | 8 +++++++- man/magma_download_binary.Rd | 7 ++++++- man/magma_install.Rd | 2 +- tests/testthat/test-magma_links.R | 19 ++++++++----------- 13 files changed, 52 insertions(+), 23 deletions(-) diff --git a/.DS_Store b/.DS_Store index 298d0b2bd2a425f71715f05a778892dbc09d4516..4d7ac4d1c8bddfa23916b50603fe46096a3042ee 100644 GIT binary patch delta 322 zcmZp1XmQw}DiFJPlMVv|0}F#5LpnnyLrHGFi%U{YeiBfOWB>YN^YjCcI-<&_;FT}P zFbq!4&n*DzVG!e(+$6A*nI$n|vYntBNB_MQ9U_KD9f2GfA%rPN!cscO+8NZrrm!%i zFeEaRFeK)rBaCKXR^2}NfnXG4z+`KoNsP&p&k2dCxaLp#BMP(tXf-oKE>KfmZa%^u xi0otz;a?`4pMXjj8G?{KyT%T#87za)2$7j=CgR3)PHS?VNCKn7=KCV5+yEtoS_c3C delta 322 zcmZp1XmQw}DiGWI?-c_B0}F#5LpnnyLrHGFi%U{YeiBfOqvv>m2AjcAM^yO~yz&JZ zhQZ1CxdlKy45A+%s86kuzNWxM&$l4iHK!yOFmco$8 zP{NRyla4T&fjL@m@&myr#tD0o$Kc1ONa4 diff --git a/DESCRIPTION b/DESCRIPTION index eedbdb1..a861f6b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", @@ -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 diff --git a/NEWS.md b/NEWS.md index 916c0df..c177f7a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# MAGMA.Celltyping 2.0.12 + +## Bug fixes + +* Update URLs for getting MAGMA executables. + # MAGMA.Celltyping 2.0.11 ## New features diff --git a/R/format_sumstats_for_magma.r b/R/format_sumstats_for_magma.r index 696c686..a61db83 100644 --- a/R/format_sumstats_for_magma.r +++ b/R/format_sumstats_for_magma.r @@ -21,6 +21,7 @@ format_sumstats_for_magma <- function(path) { mungesumstats_deprecation_msg() } + format.sumstats.for.magma <- function(path){ format_sumstats_for_magma(path) } diff --git a/R/get_genome_ref.R b/R/get_genome_ref.R index 57760d5..8188a49 100644 --- a/R/get_genome_ref.R +++ b/R/get_genome_ref.R @@ -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") diff --git a/R/list_remote_files.R b/R/list_remote_files.R index b56c746..a796a92 100644 --- a/R/list_remote_files.R +++ b/R/list_remote_files.R @@ -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) diff --git a/R/magma_download_binary.R b/R/magma_download_binary.R index 121a857..2cdf41e 100644 --- a/R/magma_download_binary.R +++ b/R/magma_download_binary.R @@ -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) diff --git a/R/magma_install.R b/R/magma_install.R index 23c945a..295efda 100644 --- a/R/magma_install.R +++ b/R/magma_install.R @@ -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] @@ -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) diff --git a/R/magma_links.R b/R/magma_links.R index 532a25b..a7232cc 100644 --- a/R/magma_links.R +++ b/R/magma_links.R @@ -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)) { @@ -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) diff --git a/R/magma_links_versions.R b/R/magma_links_versions.R index 185732e..0702be7 100644 --- a/R/magma_links_versions.R +++ b/R/magma_links_versions.R @@ -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) diff --git a/man/magma_download_binary.Rd b/man/magma_download_binary.Rd index ecc632b..9c43669 100644 --- a/man/magma_download_binary.Rd +++ b/man/magma_download_binary.Rd @@ -4,7 +4,12 @@ \alias{magma_download_binary} \title{Download a MAGMA binary} \usage{ -magma_download_binary(magma_url, dest_dir = find_install_dir(), verbose = TRUE) +magma_download_binary( + magma_url, + dest_dir = find_install_dir(), + destfile = basename(magma_url), + verbose = TRUE +) } \arguments{ \item{magma_url}{URL path to MAGMA executable.} diff --git a/man/magma_install.Rd b/man/magma_install.Rd index 699392c..f8fe490 100644 --- a/man/magma_install.Rd +++ b/man/magma_install.Rd @@ -37,5 +37,5 @@ For a list of all changes across MAGMA versions, please see \href{https://ctg.cncr.nl/software/MAGMA/doc/changelog.txt}{here}. } \examples{ -magma <- MAGMA.Celltyping::magma_install() +magma <- magma_install() } diff --git a/tests/testthat/test-magma_links.R b/tests/testthat/test-magma_links.R index 4c46631..f7066b2 100644 --- a/tests/testthat/test-magma_links.R +++ b/tests/testthat/test-magma_links.R @@ -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,