diff --git a/main.nf b/main.nf index d47e6ca5..324dac60 100644 --- a/main.nf +++ b/main.nf @@ -76,6 +76,7 @@ include { run_quac_table_report } from './modules/run_quac_table_report' include { run_quac_comparison_report } from './modules/run_quac_comparison_report' include { create_masking_report } from './modules/create_masking_report' include { update_case_count_table } from './modules/update_case_count_table' +include { run_clinical_release } from './modules/run_clinical_release' /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -83,7 +84,7 @@ include { update_case_count_table } from './modules/update_case_count_table' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -workflow { +workflow BPC_PIPELINE { ch_cohort = Channel.value(params.cohort) ch_comment = Channel.value(params.comment) @@ -104,3 +105,7 @@ workflow { THE END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +workflow CLINICAL_RELEASE { + run_clinical_release('', params.cohort, params.production) +} diff --git a/modules/run_clinical_release.nf b/modules/run_clinical_release.nf new file mode 100644 index 00000000..1127e2b6 --- /dev/null +++ b/modules/run_clinical_release.nf @@ -0,0 +1,28 @@ +process run_clinical_release { + + container 'sagebionetworks/genie-bpc-pipeline-clinical-release' + secret 'SYNAPSE_AUTH_TOKEN' + debug true + + input: + val previous + val cohort + val production + + output: + stdout + + script: + if (production) { + """ + cd /usr/local/src/myscripts/ + Rscript create_release_files.R -c $cohort -v -s + """ + } + else { + """ + cd /usr/local/src/myscripts/ + Rscript create_release_files.R -c $cohort -v + """ + } +} diff --git a/nextflow.config b/nextflow.config index 74263fc2..b2fc1f32 100644 --- a/nextflow.config +++ b/nextflow.config @@ -41,6 +41,10 @@ profiles { memory = 32.GB cpus = 8 } + withName: run_clinical_release { + memory = 32.GB + cpus = 8 + } } } } diff --git a/scripts/release/Dockerfile b/scripts/release/Dockerfile new file mode 100644 index 00000000..b41b5b55 --- /dev/null +++ b/scripts/release/Dockerfile @@ -0,0 +1,19 @@ +FROM rstudio/r-base:4.0-bullseye + +WORKDIR /usr/local/src/myscripts + +ENV RENV_VERSION 0.14.0 +# RUN rm /etc/apt/apt.conf.d/default +RUN apt-get update -y && apt-get install -y dpkg-dev zlib1g-dev libssl-dev libffi-dev curl libcurl4-openssl-dev procps + + +RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))" +RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')" +RUN R -e "remotes::install_version('synapser', version = '0.11.7', repos = c('http://ran.synapse.org', 'http://cran.fhcrc.org'))" + +ENV PYTHON /usr/local/lib/R/site-library/PythonEmbedInR/bin/python3.6 + + +COPY . . + +RUN R -e "renv::restore()" diff --git a/scripts/release/create_release_files.R b/scripts/release/create_release_files.R index f1d1ff18..01f63a04 100644 --- a/scripts/release/create_release_files.R +++ b/scripts/release/create_release_files.R @@ -27,10 +27,6 @@ option_list <- list( action="store_true", default = FALSE, help="Copy release files from staging to release folder"), - make_option(c("-a", "--auth"), - type = "character", - default = NA, - help="Synapse personal access token or path to .synapseConfig (default: normal synapse login behavior)"), make_option(c("-v", "--verbose"), action="store_true", default = FALSE, @@ -41,7 +37,6 @@ opt <- parse_args(OptionParser(option_list=option_list)) selected_cohort <- opt$cohort staging <- opt$staging release <- opt$release -auth <- opt$auth verbose <- opt$verbose if (verbose) { @@ -121,68 +116,10 @@ store_file <- function(var, } } -#' Extract personal access token from .synapseConfig -#' located at a custom path. -#' -#' @param path Path to .synapseConfig -#' @return personal acccess token -get_auth_token <- function(path) { - - lines <- scan(path, what = "character", sep = "\t", quiet = T) - line <- grep(pattern = "^authtoken = ", x = lines, value = T) - - token <- strsplit(line, split = ' ')[[1]][3] - return(token) -} - -#' Override of synapser::synLogin() function to accept -#' custom path to .synapseConfig file or personal authentication -#' token. If no arguments are supplied, performs standard synLogin(). -#' -#' @param auth full path to .synapseConfig file or authentication token -#' @param silent verbosity control on login -#' @return TRUE for successful login; F otherwise -synLogin <- function(auth = NA, silent = T) { - - secret <- Sys.getenv("SCHEDULED_JOB_SECRETS") - if (secret != "") { - # Synapse token stored as secret in json string - syn = synapser::synLogin(silent = T, authToken = fromJSON(secret)$SYNAPSE_AUTH_TOKEN) - } else if (auth == "~/.synapseConfig" || is.na(auth)) { - # default Synapse behavior - syn <- synapser::synLogin(silent = silent) - } else { - - # in case pat passed directly - token <- auth - - # extract token from custom path to .synapseConfig - if (grepl(x = auth, pattern = "\\.synapseConfig$")) { - token = get_auth_token(auth) - - if (is.na(token)) { - return(F) - } - } - - # login with token - syn <- tryCatch({ - synapser::synLogin(authToken = token, silent = silent) - }, error = function(cond) { - return(F) - }) - } - - # NULL returned indicates successful login - if (is.null(syn)) { - return(T) - } - return(F) -} # synapse login --------------- -status <- synLogin(auth = auth) +synLogin() # read --------------------