Skip to content

Commit

Permalink
Tests passing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Drucker committed Aug 13, 2024
1 parent 5bba761 commit f2e0306
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 40 deletions.
2 changes: 1 addition & 1 deletion R/PNNL_DMS_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ get_auth <- function(){
}
}


#' @importFrom RPostgres Postgres
get_db_connection <- function(
driver = Postgres,
driver_args = list(),
Expand Down
19 changes: 10 additions & 9 deletions R/read_MSstats_from_MSFragger_job.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,26 @@ read_MSstats_from_MSFragger_job <- function(data_package_num,
}

path <- unique(job_records$folder)
remote_folder <- gsub("\\\\", "/", path)
mount_folder <- local_folder <- .new_tempdir()
mount_cmd <- sprintf("mount -t smbfs %s %s", remote_folder, local_folder)
system(mount_cmd)
on.exit(system(glue("umount {mount_folder}")))

if (length(path) == 0) {
stop("No jobs found.")
}

if (.Platform$OS.type == "unix") {
remote_folder <- gsub("\\\\", "/", path)
mount_folder <- local_folder <- .new_tempdir()
mount_cmd <- sprintf("mount -t smbfs %s %s", remote_folder, local_folder)
system(mount_cmd)
on.exit(system(glue("umount {mount_folder}")))
path <- local_folder
}

if (length(path) > 1) {
stop(paste0("More than one MSFragger search found per data package.\n",
"Please refine the arguments to make sure they uniquely",
" define the MSFragger job."))
}
path_to_file <- file.path(local_folder, "MSstats.csv")
path_to_file <- file.path(path, "MSstats.csv")

if (!file.exists(path_to_file)) {
stop(sprintf("MSstats.csv file not found in %s", path))
Expand All @@ -85,9 +89,6 @@ read_MSstats_from_MSFragger_job <- function(data_package_num,
return(m)
}




utils::globalVariables(
c("Parameter_File", "Settings_File", "Organism_DB", "ProteinName",
"PeptideSequence", "Run", "Intensity", ".", "featureName")
Expand Down
21 changes: 12 additions & 9 deletions R/read_msfragger_data_from_DMS.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ read_msfragger_data_from_DMS <- function(data_package_num,
}

path <- unique(job_records$folder)
remote_folder <- gsub("\\\\", "/", path)
mount_folder <- local_folder <- .new_tempdir()
mount_cmd <- sprintf("mount -t smbfs %s %s", remote_folder, local_folder)
system(mount_cmd)
on.exit(system(glue("umount {mount_folder}")))

if (length(path) == 0) {
stop("No jobs found.")
Expand All @@ -76,21 +71,29 @@ read_msfragger_data_from_DMS <- function(data_package_num,
" define the MSFragger job."))
}

if (.Platform$OS.type == "unix") {
remote_folder <- gsub("\\\\", "/", path)
mount_folder <- local_folder <- .new_tempdir()
mount_cmd <- sprintf("mount -t smbfs %s %s", remote_folder, local_folder)
system(mount_cmd)
on.exit(system(glue("umount {mount_folder}")))
path <- local_folder
}
aggregate_zip_file_exists <- file.exists(
file.path(local_folder, "Dataset_PSM_tsv.zip"))
file.path(path, "Dataset_PSM_tsv.zip"))

if (aggregate_zip_file_exists) {
# Copy folder to temporary directory and extract psm files
aggregate_zip_file <- file.path(local_folder, "Dataset_PSM_tsv.zip")
aggregate_zip_file <- file.path(path, "Dataset_PSM_tsv.zip")
exdir <- .new_tempdir()
unzip(zipfile = aggregate_zip_file, list = FALSE, exdir = exdir)
local_folder <- exdir
path <- exdir
}

fileNamePttrn <- "_psm\\.tsv"
#
#
path_to_files <- list.files(local_folder, pattern = fileNamePttrn, full.names = TRUE)
path_to_files <- list.files(path, pattern = fileNamePttrn, full.names = TRUE)
cn <- colnames(read_tsv(path_to_files[1], n_max = 1))

# last_col <- which(cn == "Quan Usage") - 1
Expand Down
5 changes: 2 additions & 3 deletions R/read_study_design_from_DMS.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@

#' @export
#' @rdname read_study_design
path_to_study_design_from_DMS <- function(data_package_num,
useHTTP = FALSE)
path_to_study_design_from_DMS <- function(data_package_num)
{

con <- get_db_connection()
Expand All @@ -59,7 +58,7 @@ path_to_study_design_from_DMS <- function(data_package_num,
dataPkgReport <- dbFetch(qry)
dbClearResult(qry)

if(.Platform$OS.type == "unix" | useHTTP){
if(.Platform$OS.type == "unix"){
local_folder <- .new_tempdir()

remote_folder <- gsub("\\\\","/", dataPkgReport$share_path)
Expand Down
2 changes: 1 addition & 1 deletion man/read_study_design.Rd

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

35 changes: 18 additions & 17 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,37 @@ library(testthat)

path_check <- function(path) {
expect_true(grepl("Rtmp", path, ignore.case = FALSE))
system(glue::glue("umount {path}"))
if (.Platform$OS.type == "unix") {
system(glue::glue("umount {path}"))
}
}
cat("1------\n")
# cat("1------\n")
expect_true(is_PNNL_DMS_connection_successful())
cat("2------\n")
# cat("2------\n")
expect_equal(dim(get_dms_job_records(4232)), c(1, 23))
cat("3------\n")
# cat("3------\n")
expect_equal(get_output_folder_for_job_and_tool(2344924, "DiaNN"), "DNN202408121049_Auto2344924")
cat("4------\n")
# cat("4------\n")
expect_equal(dim(get_job_records_by_dataset_package(4232)), c(2, 22))
cat("5------\n")
# cat("5------\n")
expect_equal(dim(get_datasets_by_data_package(4232)), c(1, 13))
cat("6------\n")
# cat("6------\n")
path <- path_to_FASTA_used_by_DMS(4232)
path_check(path)
expect_equal(dim(read_AScore_results_from_DMS(4136)), c(916130, 12)) # check args
cat("7------\n")
# cat("7------\n")
path <- path_to_study_design_from_DMS(4232)
path_check(path)
cat("8------\n")
path <- path_to_study_design_from_DMS(4232, T)
path_check(path)
cat("9------\n")
if (.Platform$OS.type == "unix") {
path_check(path)
}
# cat("8------\n")
expect_equal(dim(read_masic_data_from_DMS(4232)), c(20938, 22)) # check args
cat("10------\n")
expect_equal(dim(read_msfragger_data_from_DMS(
# cat("9------\n")
expect_equal(dim(read_msfragger_data_from_DMS( # Fail
4804,
"MSFragger_Tryp_ProlineRule_ProtNTermAcet_Stat_CysAlk_TMT_6Plex_20ppmParTol.params",
"MSFragger_PepFDR_0.99_ProtFDR_0.99_IncludeDecoys.xml",
"ID_008350_56958B5A.fasta"
)), c(266203, 11))

# cat("11------\n")
expect_equal(dim(read_AScore_results_from_DMS(4136)), c(916130, 12)) # check args
# get_tool_output_files_for_job_number(2344924, fileNamePttrn = ".") -> res

0 comments on commit f2e0306

Please sign in to comment.