Skip to content

Commit

Permalink
Allow two locations for a file
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Dec 16, 2022
1 parent a6f5c94 commit 890677f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
22 changes: 19 additions & 3 deletions R/get_trained_mhc_1_haplotypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,28 @@ get_trained_mhc_1_haplotypes <- function(
basename(get_mhcnuggets_url())
)
testthat::expect_true(dir.exists(mhcnuggets_folder))
alleles_filename <- normalizePath(
alleles_filename_1 <- normalizePath(
file.path(
mhcnuggets_folder,
"data", "production", "mhcI", "alleles_with_trained_models.txt"
), mustWork = FALSE
)
mhcnuggetsr::check_file_exists(alleles_filename)
readLines(alleles_filename)
alleles_filename_2 <- normalizePath(
file.path(
mhcnuggets_folder,
"mhcnuggets",
"data", "production", "mhcI", "alleles_with_trained_models.txt"
), mustWork = FALSE
)
if (file.exists(alleles_filename_1)) {
return(readLines(alleles_filename_1))
}
if (file.exists(alleles_filename_2)) {
return(readLines(alleles_filename_2))
}
stop(
"Could not find a file at neither ",
alleles_filename_1, " nor ",
alleles_filename_2
)
}
22 changes: 19 additions & 3 deletions R/get_trained_mhc_2_haplotypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,28 @@ get_trained_mhc_2_haplotypes <- function(
basename(get_mhcnuggets_url())
)
testthat::expect_true(dir.exists(mhcnuggets_folder))
alleles_filename <- normalizePath(
alleles_filename_1 <- normalizePath(
file.path(
mhcnuggets_folder,
"data", "production", "mhcII", "alleles_with_trained_models.txt"
), mustWork = FALSE
)
mhcnuggetsr::check_file_exists(alleles_filename)
readLines(alleles_filename)
alleles_filename_2 <- normalizePath(
file.path(
mhcnuggets_folder,
"mhcnuggets",
"data", "production", "mhcII", "alleles_with_trained_models.txt"
), mustWork = FALSE
)
if (file.exists(alleles_filename_1)) {
return(readLines(alleles_filename_1))
}
if (file.exists(alleles_filename_2)) {
return(readLines(alleles_filename_2))
}
stop(
"Could not find a file at neither ",
alleles_filename_1, " nor ",
alleles_filename_2
)
}

0 comments on commit 890677f

Please sign in to comment.