diff --git a/.github/workflows/update-loci.yaml b/.github/workflows/update-loci.yaml index 9464a34..fe565ae 100644 --- a/.github/workflows/update-loci.yaml +++ b/.github/workflows/update-loci.yaml @@ -2,6 +2,7 @@ name: Update data permissions: contents: write + pull-requests: write on: pull_request: @@ -11,6 +12,8 @@ on: - "scripts/**" - "workflow/**" - ".github/workflows/**" + schedule: + - cron: "45 2 1 * *" # Run monthly at 2:45 am workflow_dispatch: jobs: @@ -41,9 +44,29 @@ jobs: conda info - name: Check loci and update bed files (short) - #if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'}} + if: ${{ github.event_name == 'pull_request'}} run: snakemake --config stages="skip-refs" + # Enable this step to open an SSH session for debugging + # - name: SSH debug + # uses: mxschmitt/action-tmate@v3 + + - name: Find new literature (intermediate) + if: ${{ github.event_name == 'workflow_dispatch' }} + run: | + conda init + source /home/runner/.bashrc + conda activate strchive + snakemake --config stages="new-refs" + + - name: Update all literature (long) + if: ${{ github.event_name == 'schedule' }} + run: | + conda init + source /home/runner/.bashrc + conda activate strchive + snakemake + - name: Open pull request with updated files if: ${{ !(github.event_name == 'pull_request') }} uses: peter-evans/create-pull-request@v7 @@ -55,4 +78,4 @@ jobs: if: ${{ github.event_name == 'pull_request' }} uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: Update data \ No newline at end of file + commit_message: Update data diff --git a/scripts/environment.yml b/scripts/environment.yml index 21b16fd..05d7870 100644 --- a/scripts/environment.yml +++ b/scripts/environment.yml @@ -13,7 +13,9 @@ dependencies: - jsbeautifier - statsmodels - plotly + - zlib - r-essentials + - r-base - r-jsonlite - r-dplyr - r-rentrez diff --git a/scripts/get-literature.R b/scripts/get-literature.R index 8c5c150..4c39ac2 100644 --- a/scripts/get-literature.R +++ b/scripts/get-literature.R @@ -4,14 +4,26 @@ # More useful error messages options(error=traceback) +## Set default CRAN mirror +local({r <- getOption("repos") + r["CRAN"] <- "https://cran.r-project.org" + options(repos=r) +}) + # Install biomaRt if not already installed -if (!requireNamespace("biomaRt", quietly = TRUE)) { - if (!requireNamespace("BiocManager", quietly = TRUE)) { - install.packages("BiocManager") +tryCatch({ + if (!requireNamespace("biomaRt", quietly = TRUE)) { + if (!requireNamespace("BiocManager", quietly = TRUE)) { + install.packages("BiocManager", ask = FALSE, update = FALSE) + } + BiocManager::install("biomaRt", ask = FALSE) } - BiocManager::install("biomaRt") -} +}, error = function(e) { + cat("Error installing biomaRt package.\n", file=stderr()) + quit(status = 1) +}) +tryCatch({ suppressPackageStartupMessages({ library(jsonlite) library(dplyr) @@ -21,6 +33,10 @@ suppressPackageStartupMessages({ library(stringr) library(purrr) }) +}, error = function(e) { + cat("Error loading required packages.\n", file=stderr()) + quit(status = 1) +}) ### Data Setup args <- commandArgs(trailingOnly = TRUE) diff --git a/scripts/setup-miniconda-patched-environment.yml b/scripts/setup-miniconda-patched-environment.yml index 53ed2ed..846942e 100644 --- a/scripts/setup-miniconda-patched-environment.yml +++ b/scripts/setup-miniconda-patched-environment.yml @@ -11,7 +11,9 @@ dependencies: - jsbeautifier - statsmodels - plotly + - zlib - r-essentials + - r-base - r-jsonlite - r-dplyr - r-rentrez