diff --git a/R/calculatePeptideBindingLoad.R b/R/calculatePeptideBindingLoad.R index 9730c20..29500b9 100644 --- a/R/calculatePeptideBindingLoad.R +++ b/R/calculatePeptideBindingLoad.R @@ -536,6 +536,14 @@ calculatePeptideBindingLoad <- function( #' #' @keywords internal .predictBindingMHCnuggets <- function(peptides, alleles) { + # Windows not supported for MHCnuggets + + if (.Platform$OS.type == "windows") { + stop("MHCnuggets backend is not supported on Windows due to TensorFlow/HDF5 path limitations. ", + "Please use backend='pwm' or backend='netmhcpan' instead.", + call. = FALSE) + } + results <- data.frame( peptide = character(0), hla_allele = character(0), @@ -543,7 +551,6 @@ calculatePeptideBindingLoad <- function( stringsAsFactors = FALSE ) - # Run predictions for each allele for (allele in alleles) { # Determine MHC class from allele name diff --git a/R/mhcnuggets.R b/R/mhcnuggets.R index 5d28f4d..2b33724 100644 --- a/R/mhcnuggets.R +++ b/R/mhcnuggets.R @@ -41,13 +41,18 @@ #' } #' #' @examples -#' res <- predictMHCnuggets( -#' peptides = c("SIINFEKL","LLFGYPVYV"), -#' allele = "A*02:01", -#' mhc_class = "I", -#' rank_output = TRUE -#' ) -#' head(res) +#' \donttest{ +#' # MHCnuggets requires Python/TensorFlow and is not available on Windows +#' if (.Platform$OS.type != "windows") { +#' res <- predictMHCnuggets( +#' peptides = c("SIINFEKL","LLFGYPVYV"), +#' allele = "A*02:01", +#' mhc_class = "I", +#' rank_output = TRUE +#' ) +#' head(res) +#' } +#' } #' #' @section License and Citation: #' mhcnuggets is licensed under the GNU General Public License v3.0. @@ -73,6 +78,13 @@ predictMHCnuggets <- function(peptides, ba_models = FALSE, rank_output = FALSE, hla_env = deepmatchrEnv()) { + # ---- Windows not supported ---- + if (.Platform$OS.type == "windows") { + stop("MHCnuggets is not supported on Windows due to TensorFlow/HDF5 path limitations. ", + "Please use the 'pwm' or 'netmhcpan' backend, or run on Linux/macOS.", + call. = FALSE) + } + # ---- fast input checks ---- if (!is.character(peptides)) stop("`peptides` must be character.") if (!length(peptides)) return(data.frame(peptide = character(0L))) diff --git a/man/predictMHCnuggets.Rd b/man/predictMHCnuggets.Rd index 262d324..a4e8bf4 100644 --- a/man/predictMHCnuggets.Rd +++ b/man/predictMHCnuggets.Rd @@ -87,12 +87,17 @@ GitHub: https://github.com/KarchinLab/mhcnuggets } \examples{ -res <- predictMHCnuggets( - peptides = c("SIINFEKL","LLFGYPVYV"), - allele = "A*02:01", - mhc_class = "I", - rank_output = TRUE -) -head(res) +\donttest{ +# MHCnuggets requires Python/TensorFlow and is not available on Windows +if (.Platform$OS.type != "windows") { + res <- predictMHCnuggets( + peptides = c("SIINFEKL","LLFGYPVYV"), + allele = "A*02:01", + mhc_class = "I", + rank_output = TRUE + ) + head(res) +} +} } diff --git a/tests/testthat/test-predictMHCnuggets.R b/tests/testthat/test-predictMHCnuggets.R index 7fe9f1d..d1668b6 100644 --- a/tests/testthat/test-predictMHCnuggets.R +++ b/tests/testthat/test-predictMHCnuggets.R @@ -4,6 +4,18 @@ testthat::local_edition(3) testthat::skip_if_not_installed("basilisk") testthat::skip_if_not_installed("reticulate") +# Test Windows error handling first (before skipping on Windows) +test_that("predictMHCnuggets errors on Windows", { + testthat::skip_if_not(.Platform$OS.type == "windows", "Only runs on Windows") + expect_error( + predictMHCnuggets(peptides = "SIINFEKL", allele = "A*02:01"), + "not supported on Windows" + ) +}) + +# Skip remaining tests on Windows since MHCnuggets is not supported +testthat::skip_on_os("windows") + # Capture arguments passed through basiliskRun for assertions .observed <- new.env(parent = emptyenv())