Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion R/calculatePeptideBindingLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,21 @@ 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),
predicted_ic50 = numeric(0),
stringsAsFactors = FALSE
)


# Run predictions for each allele
for (allele in alleles) {
# Determine MHC class from allele name
Expand Down
26 changes: 19 additions & 7 deletions R/mhcnuggets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)))
Expand Down
19 changes: 12 additions & 7 deletions man/predictMHCnuggets.Rd

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

12 changes: 12 additions & 0 deletions tests/testthat/test-predictMHCnuggets.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down