diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..06f46ec --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,5 @@ +^.*\.Rproj$ +^\.Rproj\.user$ +^\.github$ +^\.travis\.yml$ +^LICENSE\.md$ diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index bc4398a..b7bad7d 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -1,310 +1,310 @@ -## Read more about GitHub actions the features of this GitHub Actions workflow -## at https://lcolladotor.github.io/biocthis/articles/biocthis.html#use_bioc_github_action -## -## For more details, check the biocthis developer notes vignette at -## https://lcolladotor.github.io/biocthis/articles/biocthis_dev_notes.html -## -## You can add this workflow to other packages using: -## > biocthis::use_bioc_github_action() -## -## Using GitHub Actions exposes you to many details about how R packages are -## compiled and installed in several operating system.s -### If you need help, please follow the steps listed at -## https://github.com/r-lib/actions#where-to-find-help -## -## If you found an issue specific to biocthis's GHA workflow, please report it -## with the information that will make it easier for others to help you. -## Thank you! - -## Acronyms: -## * GHA: GitHub Action -## * OS: operating system - -on: - push: - pull_request: - -name: R-CMD-check-bioc - -## These environment variables control whether to run GHA code later on that is -## specific to testthat, covr, and pkgdown. -## -## If you need to clear the cache of packages, update the number inside -## cache-version as discussed at https://github.com/r-lib/actions/issues/86. -## Note that you can always run a GHA test without the cache by using the word -## "/nocache" in the commit message. -env: - has_testthat: 'true' - run_covr: 'true' - run_pkgdown: 'true' - has_RUnit: 'false' - has_BiocCheck: 'false' - cache-version: 'cache-v1' - -jobs: - build-check: - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - container: ${{ matrix.config.cont }} - ## Environment variables unique to this job. - - strategy: - fail-fast: false - matrix: - config: - - { os: ubuntu-latest, r: 'devel', bioc: '3.19', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - #- { os: macOS-latest, r: 'devel', bioc: '3.19'} - #- { os: windows-latest, r: 'devel', bioc: '3.19'} - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - NOT_CRAN: true - TZ: UTC - VDIFFR_RUN_TESTS: false - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - ## Set the R library to the directory matching the - ## R packages cache step further below when running on Docker (Linux). - - name: Set R Library home on Linux - if: runner.os == 'Linux' - run: | - mkdir /__w/_temp/Library - echo ".libPaths('/__w/_temp/Library')" > ~/.Rprofile - - ## Most of these steps are the same as the ones in - ## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml - ## If they update their steps, we will also need to update ours. - - name: Checkout Repository - uses: actions/checkout@v2 - - ## R is already included in the Bioconductor docker images - - name: Setup R from r-lib - if: runner.os != 'Linux' - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - ## pandoc is already included in the Bioconductor docker images - - name: Setup pandoc from r-lib - if: runner.os != 'Linux' - uses: r-lib/actions/setup-pandoc@v2 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - shell: Rscript {0} - - - name: Cache R packages - if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'" - uses: actions/cache@v3 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel- - - - name: Cache R packages on Linux - if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " - uses: actions/cache@v3 - with: - path: /home/runner/work/_temp/Library - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel- - - - name: Install Linux system dependencies - if: runner.os == 'Linux' - run: | - sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))') - echo $sysreqs - sudo -s eval "$sysreqs" - - # in addition install tesseract - - sudo apt-get install -y libtesseract-dev libleptonica-dev - - - name: Install macOS system dependencies - if: matrix.config.os == 'macOS-latest' - run: | - ## Enable installing XML from source if needed - brew install libxml2 - echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV - - ## Required to install magick as noted at - ## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2 - brew install imagemagick@6 - - ## For textshaping, required by ragg, and required by pkgdown - brew install harfbuzz fribidi - - brew install libgit2 - ## Helps compile RCurl from source - ## brew uninstall curl - - ## required for ncdf4 - can not use the homebrew one because that uses GCC - ## Use pre-compiled libraries from https://mac.r-project.org/libs-4/ - curl -O https://mac.r-project.org/libs-4/netcdf-4.7.4-darwin.17-x86_64.tar.gz - tar fvxzm netcdf-4.7.4-darwin.17-x86_64.tar.gz -C / - rm netcdf-4.7.4-darwin.17-x86_64.tar.gz - curl -O https://mac.r-project.org/libs-4/hdf5-1.12.0-darwin.17-x86_64.tar.gz - tar fvxzm hdf5-1.12.0-darwin.17-x86_64.tar.gz -C / - rm hdf5-1.12.0-darwin.17-x86_64.tar.gz - curl -O https://mac.r-project.org/libs-4/szip-2.1.1-darwin.17-x86_64.tar.gz - tar fvxzm szip-2.1.1-darwin.17-x86_64.tar.gz -C / - rm szip-2.1.1-darwin.17-x86_64.tar.gz - - - name: Install Windows system dependencies - if: runner.os == 'Windows' - run: | - ## Edit below if you have any Windows system dependencies - shell: Rscript {0} - - - name: Install BiocManager - run: | - message(paste('****', Sys.time(), 'installing BiocManager ****')) - remotes::install_cran("BiocManager") - shell: Rscript {0} - - - name: Set BiocVersion - run: | - BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE) - shell: Rscript {0} - - - name: Install dependencies - run: | - ## Try installing the package dependencies in steps. First the local - ## dependencies, then any remaining dependencies to avoid the - ## issues described at - ## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html - ## https://github.com/r-lib/remotes/issues/296 - ## Ideally, all dependencies should get installed in the first pass. - - ## Pass #1 at installing dependencies - BiocManager::install("RforMassSpectrometry/ProtGenerics", ask = FALSE,force = TRUE) - message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****')) - remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) - BiocManager::install("RforMassSpectrometry/MsCoreUtils", ask = FALSE, force = TRUE) - ## Pass #2 at installing dependencies - message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****')) - - ## Temporaly use the development version of RMassBankData - ## remotes::install_github(repo = "MassBank/RMassBankData") - - remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) - - ## Manually install required packages - BiocManager::install('rhdf5', dependencies = TRUE, ask = FALSE, update = FALSE, INSTALL_opts = '--force-biarch') - BiocManager::install("sneumann/mzR", dependencies = TRUE, ask = FALSE, update=FALSE) - BiocManager::install("SummarizedExperiment", ask = FALSE, update = FALSE) - BiocManager::install("msdata") - BiocManager::install("magick", dependencies = TRUE, ask = FALSE, update=FALSE) - - # BiocManager::install(c("devtools", "usethis", "vdiffr"), dependencies = TRUE, ask = FALSE, update = FALSE) - ## For running the checks - message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****')) - remotes::install_cran("rcmdcheck") - BiocManager::install("BiocCheck") - shell: Rscript {0} - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - - name: Install BiocGenerics - if: env.has_RUnit == 'true' - run: | - ## Install BiocGenerics - BiocManager::install("BiocGenerics") - shell: Rscript {0} - - - name: Install covr - if: github.ref == 'refs/heads/main' && env.run_covr == 'true' && runner.os == 'Linux' - run: | - remotes::install_cran("covr") - shell: Rscript {0} - - - name: Install pkgdown - if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' - run: | - remotes::install_github("r-lib/pkgdown") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Save cache (Linux) - uses: actions/cache/save@v3 - if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " - with: - path: /home/runner/work/_temp/Library - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} - - - name: Run CMD check - if: "!contains(github.event.head_commit.message, '/nocheck')" - env: - _R_CHECK_CRAN_INCOMING_: false - run: | - rcmdcheck::rcmdcheck( - args = c("--no-build-vignettes", "--no-manual", "--timings"), - build_args = c("--no-manual", "--no-resave-data"), - error_on = "warning", - check_dir = "check" - ) - shell: Rscript {0} - - ## Might need an to add this to the if: && runner.os == 'Linux' - - name: Reveal testthat details - if: "env.has_testthat == 'true' && !contains(github.event.head_commit.message, '/nocheck')" - run: find . -name testthat.Rout -exec cat '{}' ';' - - - name: Run RUnit tests - if: "env.has_RUnit == 'true' && !contains(github.event.head_commit.message, '/nocheck')" - run: | - BiocGenerics:::testPackage() - shell: Rscript {0} - - - name: Run BiocCheck - if: "env.has_BiocCheck == 'true' && !contains(github.event.head_commit.message, '/nocheck')" - run: | - BiocCheck::BiocCheck( - dir('check', 'tar.gz$', full.names = TRUE), - `quit-with-status` = TRUE, - `no-check-R-ver` = TRUE, - `no-check-bioc-help` = TRUE - ) - shell: Rscript {0} - - - name: Test coverage - if: github.ref == 'refs/heads/main' && env.run_covr == 'true' && runner.os == 'Linux' - run: | - covr::codecov() - shell: Rscript {0} - - - name: Install package - if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' - run: R CMD INSTALL . - - - name: Deploy package - if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - git config --global --add safe.directory /__w/RMassBank/RMassBank - Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)" - shell: bash {0} - ## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE) - ## at least one locally before this will work. This creates the gh-pages - ## branch (erasing anything you haven't version controlled!) and - ## makes the git history recognizable by pkgdown. - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@master - with: - name: ${{ runner.os }}-biocversion-devel-r-devel-results - path: check +## Read more about GitHub actions the features of this GitHub Actions workflow +## at https://lcolladotor.github.io/biocthis/articles/biocthis.html#use_bioc_github_action +## +## For more details, check the biocthis developer notes vignette at +## https://lcolladotor.github.io/biocthis/articles/biocthis_dev_notes.html +## +## You can add this workflow to other packages using: +## > biocthis::use_bioc_github_action() +## +## Using GitHub Actions exposes you to many details about how R packages are +## compiled and installed in several operating system.s +### If you need help, please follow the steps listed at +## https://github.com/r-lib/actions#where-to-find-help +## +## If you found an issue specific to biocthis's GHA workflow, please report it +## with the information that will make it easier for others to help you. +## Thank you! + +## Acronyms: +## * GHA: GitHub Action +## * OS: operating system + +on: + push: + pull_request: + +name: R-CMD-check-bioc + +## These environment variables control whether to run GHA code later on that is +## specific to testthat, covr, and pkgdown. +## +## If you need to clear the cache of packages, update the number inside +## cache-version as discussed at https://github.com/r-lib/actions/issues/86. +## Note that you can always run a GHA test without the cache by using the word +## "/nocache" in the commit message. +env: + has_testthat: 'true' + run_covr: 'true' + run_pkgdown: 'true' + has_RUnit: 'false' + has_BiocCheck: 'false' + cache-version: 'cache-v1' + +jobs: + build-check: + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + container: ${{ matrix.config.cont }} + ## Environment variables unique to this job. + + strategy: + fail-fast: false + matrix: + config: + - { os: ubuntu-latest, r: 'devel', bioc: '3.23', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } + #- { os: macOS-latest, r: 'devel', bioc: '3.19'} + #- { os: windows-latest, r: 'devel', bioc: '3.19'} + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + NOT_CRAN: true + TZ: UTC + VDIFFR_RUN_TESTS: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + + ## Set the R library to the directory matching the + ## R packages cache step further below when running on Docker (Linux). + - name: Set R Library home on Linux + if: runner.os == 'Linux' + run: | + mkdir /__w/_temp/Library + echo ".libPaths('/__w/_temp/Library')" > ~/.Rprofile + + ## Most of these steps are the same as the ones in + ## https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml + ## If they update their steps, we will also need to update ours. + - name: Checkout Repository + uses: actions/checkout@v2 + + ## R is already included in the Bioconductor docker images + - name: Setup R from r-lib + if: runner.os != 'Linux' + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + + ## pandoc is already included in the Bioconductor docker images + - name: Setup pandoc from r-lib + if: runner.os != 'Linux' + uses: r-lib/actions/setup-pandoc@v2 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + shell: Rscript {0} + + - name: Cache R packages + if: "!contains(github.event.head_commit.message, '/nocache') && runner.os != 'Linux'" + uses: actions/cache@v3 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel- + + - name: Cache R packages on Linux + if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " + uses: actions/cache@v3 + with: + path: /home/runner/work/_temp/Library + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel- + + - name: Install Linux system dependencies + if: runner.os == 'Linux' + run: | + sysreqs=$(Rscript -e 'cat("apt-get update -y && apt-get install -y", paste(gsub("apt-get install -y ", "", remotes::system_requirements("ubuntu", "20.04")), collapse = " "))') + echo $sysreqs + sudo -s eval "$sysreqs" + + # in addition install tesseract + + sudo apt-get install -y libtesseract-dev libleptonica-dev + + - name: Install macOS system dependencies + if: matrix.config.os == 'macOS-latest' + run: | + ## Enable installing XML from source if needed + brew install libxml2 + echo "XML_CONFIG=/usr/local/opt/libxml2/bin/xml2-config" >> $GITHUB_ENV + + ## Required to install magick as noted at + ## https://github.com/r-lib/usethis/commit/f1f1e0d10c1ebc75fd4c18fa7e2de4551fd9978f#diff-9bfee71065492f63457918efcd912cf2 + brew install imagemagick@6 + + ## For textshaping, required by ragg, and required by pkgdown + brew install harfbuzz fribidi + + brew install libgit2 + ## Helps compile RCurl from source + ## brew uninstall curl + + ## required for ncdf4 - can not use the homebrew one because that uses GCC + ## Use pre-compiled libraries from https://mac.r-project.org/libs-4/ + curl -O https://mac.r-project.org/libs-4/netcdf-4.7.4-darwin.17-x86_64.tar.gz + tar fvxzm netcdf-4.7.4-darwin.17-x86_64.tar.gz -C / + rm netcdf-4.7.4-darwin.17-x86_64.tar.gz + curl -O https://mac.r-project.org/libs-4/hdf5-1.12.0-darwin.17-x86_64.tar.gz + tar fvxzm hdf5-1.12.0-darwin.17-x86_64.tar.gz -C / + rm hdf5-1.12.0-darwin.17-x86_64.tar.gz + curl -O https://mac.r-project.org/libs-4/szip-2.1.1-darwin.17-x86_64.tar.gz + tar fvxzm szip-2.1.1-darwin.17-x86_64.tar.gz -C / + rm szip-2.1.1-darwin.17-x86_64.tar.gz + + - name: Install Windows system dependencies + if: runner.os == 'Windows' + run: | + ## Edit below if you have any Windows system dependencies + shell: Rscript {0} + + - name: Install BiocManager + run: | + message(paste('****', Sys.time(), 'installing BiocManager ****')) + remotes::install_cran("BiocManager") + shell: Rscript {0} + + - name: Set BiocVersion + run: | + BiocManager::install(version = "${{ matrix.config.bioc }}", ask = FALSE) + shell: Rscript {0} + + - name: Install dependencies + run: | + ## Try installing the package dependencies in steps. First the local + ## dependencies, then any remaining dependencies to avoid the + ## issues described at + ## https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016675.html + ## https://github.com/r-lib/remotes/issues/296 + ## Ideally, all dependencies should get installed in the first pass. + + ## Pass #1 at installing dependencies + BiocManager::install("RforMassSpectrometry/ProtGenerics", ask = FALSE,force = TRUE) + message(paste('****', Sys.time(), 'pass number 1 at installing dependencies: local dependencies ****')) + remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) + BiocManager::install("RforMassSpectrometry/MsCoreUtils", ask = FALSE, force = TRUE) + ## Pass #2 at installing dependencies + message(paste('****', Sys.time(), 'pass number 2 at installing dependencies: any remaining dependencies ****')) + + ## Temporaly use the development version of RMassBankData + ## remotes::install_github(repo = "MassBank/RMassBankData") + + remotes::install_local(dependencies = TRUE, repos = BiocManager::repositories(), build_vignettes = TRUE, upgrade = TRUE) + + ## Manually install required packages + BiocManager::install('rhdf5', dependencies = TRUE, ask = FALSE, update = FALSE, INSTALL_opts = '--force-biarch') + BiocManager::install("sneumann/mzR", dependencies = TRUE, ask = FALSE, update=FALSE) + BiocManager::install("SummarizedExperiment", ask = FALSE, update = FALSE) + BiocManager::install("msdata") + BiocManager::install("magick", dependencies = TRUE, ask = FALSE, update=FALSE) + + # BiocManager::install(c("devtools", "usethis", "vdiffr"), dependencies = TRUE, ask = FALSE, update = FALSE) + ## For running the checks + message(paste('****', Sys.time(), 'installing rcmdcheck and BiocCheck ****')) + remotes::install_cran("rcmdcheck") + BiocManager::install("BiocCheck") + shell: Rscript {0} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + - name: Install BiocGenerics + if: env.has_RUnit == 'true' + run: | + ## Install BiocGenerics + BiocManager::install("BiocGenerics") + shell: Rscript {0} + + - name: Install covr + if: github.ref == 'refs/heads/main' && env.run_covr == 'true' && runner.os == 'Linux' + run: | + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Install pkgdown + if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' + run: | + remotes::install_github("r-lib/pkgdown") + shell: Rscript {0} + + - name: Session info + run: | + options(width = 100) + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - name: Save cache (Linux) + uses: actions/cache/save@v3 + if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " + with: + path: /home/runner/work/_temp/Library + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-devel-r-devel-${{ hashFiles('.github/depends.Rds') }} + + - name: Run CMD check + if: "!contains(github.event.head_commit.message, '/nocheck')" + env: + _R_CHECK_CRAN_INCOMING_: false + run: | + rcmdcheck::rcmdcheck( + args = c("--no-build-vignettes", "--no-manual", "--timings"), + build_args = c("--no-manual", "--no-resave-data"), + error_on = "warning", + check_dir = "check" + ) + shell: Rscript {0} + + ## Might need an to add this to the if: && runner.os == 'Linux' + - name: Reveal testthat details + if: "env.has_testthat == 'true' && !contains(github.event.head_commit.message, '/nocheck')" + run: find . -name testthat.Rout -exec cat '{}' ';' + + - name: Run RUnit tests + if: "env.has_RUnit == 'true' && !contains(github.event.head_commit.message, '/nocheck')" + run: | + BiocGenerics:::testPackage() + shell: Rscript {0} + + - name: Run BiocCheck + if: "env.has_BiocCheck == 'true' && !contains(github.event.head_commit.message, '/nocheck')" + run: | + BiocCheck::BiocCheck( + dir('check', 'tar.gz$', full.names = TRUE), + `quit-with-status` = TRUE, + `no-check-R-ver` = TRUE, + `no-check-bioc-help` = TRUE + ) + shell: Rscript {0} + + - name: Test coverage + if: github.ref == 'refs/heads/main' && env.run_covr == 'true' && runner.os == 'Linux' + run: | + covr::codecov() + shell: Rscript {0} + + - name: Install package + if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' + run: R CMD INSTALL . + + - name: Deploy package + if: github.ref == 'refs/heads/main' && env.run_pkgdown == 'true' && runner.os == 'Linux' + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + git config --global --add safe.directory /__w/RMassBank/RMassBank + Rscript -e "pkgdown::deploy_to_branch(new_process = FALSE)" + shell: bash {0} + ## Note that you need to run pkgdown::deploy_to_branch(new_process = FALSE) + ## at least one locally before this will work. This creates the gh-pages + ## branch (erasing anything you haven't version controlled!) and + ## makes the git history recognizable by pkgdown. + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@master + with: + name: ${{ runner.os }}-biocversion-devel-r-devel-results + path: check diff --git a/.gitignore b/.gitignore index 62bcd8e..2d902e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .RData -.Rbuildignore .Rhistory .Rproj.user *.Rproj diff --git a/DESCRIPTION b/DESCRIPTION index 5b41250..ca25b3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: RMassBank Title: Workflow to process tandem MS files and build MassBank records -Version: 3.22.1 +Version: 3.22.2 Authors@R: c( person("RMassBank at Eawag", , , "massbank@eawag.ch", role = "cre"), person("Michael A.", "Stravs", , "michael.stravs@eawag.ch", role = "aut", @@ -27,7 +27,8 @@ Description: Workflow to process tandem MS files and build MassBank of compound information from Internet databases, and export to MassBank records. License: Artistic-2.0 -Depends: +Depends: + R (>= 4.1.0), Rcpp Imports: assertthat, @@ -51,6 +52,7 @@ Imports: readr, rjson, S4Vectors, + stringr, tibble, tidyselect, webchem, @@ -71,7 +73,7 @@ VignetteBuilder: biocViews: ImmunoOncology, Bioinformatics, MassSpectrometry, Metabolomics, Software Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.3 SystemRequirements: OpenBabel Collate: 'alternateAnalyze.R' diff --git a/NAMESPACE b/NAMESPACE index 3d8737d..01bae52 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -176,6 +176,7 @@ import(rcdk) import(readJDX) import(readr) import(rjson) +import(stringr) import(tibble) import(yaml) importFrom(Biobase,"classVersion<-") diff --git a/R/createMassBank.R b/R/createMassBank.R index e8b7dea..1ba155a 100755 --- a/R/createMassBank.R +++ b/R/createMassBank.R @@ -732,7 +732,7 @@ gatherData <- function(id) # Get the api key from the settings ccte_api_key = getOption("RMassBank")$settings$ccte_api_key - if(!is.null(api_key)) { + if(!is.null(ccte_api_key)) { dtxsid <- getDTXSID(key = inchikey_split, api_key = ccte_api_key) if(is.null(dtxsid)){ diff --git a/R/webAccess.R b/R/webAccess.R index 6563e7e..106ccd9 100755 --- a/R/webAccess.R +++ b/R/webAccess.R @@ -791,7 +791,7 @@ getPcSDF <- function(query, from = "smiles"){ #' Retrieves ChemSpider CSID from UK RSC for a search term. #' #' Requires a valid API key -#' @usage getCSID(key, api_key) +#' @usage getCSID(key, identifier, api_key) #' @param key ID to be converted #' @param identifier identifier (name, inchikey) #' @param api_key API key for ChemSpider (to be created on the developer site) @@ -804,7 +804,7 @@ getPcSDF <- function(query, from = "smiles"){ #' \url{https://developer.rsc.org/api-reference#} #' @examples #' \dontrun{ -#' getDTXSID(key = "MKXZASYAUGDDCJ-NJAFHUGGSA-N", identifier = "InChIKey", api_key = "your key") +#' getDTXSID(key = "MKXZASYAUGDDCJ-NJAFHUGGSA-N", identifier = "InChIKey", api_key = "your RCS API key") #' } #' @export getCSID <- function(key, identifier, api_key) diff --git a/R/zzz.R b/R/zzz.R index b64f86b..e5f7726 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,56 +1,57 @@ -# Central import section - -#' @importFrom assertthat assert_that has_args -#' @importFrom Biobase isVersioned isCurrent classVersion<- classVersion -#' @importFrom ChemmineR smiles2sdf validSDF write.SDF -#' @importFrom data.table fread fwrite -#' @import digest -#' @importFrom dplyr rename_with select -#' @import glue -#' @import httr -#' @import httr2 -#' @import logger -#' @importFrom methods setGeneric setMethod -#' @import mzR -#' @import rcdk -#' @import Rcpp -#' @import readJDX -#' @import readr -#' @import rjson -#' @import S4Vectors -#' @importFrom stats lm loess median predict smooth.spline -#' @import tibble -#' @importFrom tidyselect everything -#' @importFrom utils URLencode capture.output data flush.console -#' @importFrom utils packageVersion read.csv read.csv2 setTxtProgressBar -#' @importFrom utils str txtProgressBar type.convert write.csv write.table -#' @importFrom utils globalVariables -#' @importFrom webchem cir_query -#' @import XML -#' @import yaml - - -.onLoad <- function(libname, pkgname) { - RMassBank.env <<- new.env() - RMassBank.env$ReadAnnotation <- FALSE - RMassBank.env$testnumber <- 1 - ## new variables - RMassBank.env$verbose.output <- FALSE - RMassBank.env$export.invalid <- FALSE - RMassBank.env$export.molfiles <- TRUE - RMassBank.env$strictMsMsSpectraSelection <- FALSE - - mb <- list() - attach(RMassBank.env) -} - -utils::globalVariables(c("cpdID", - "isotopes", - "mzCalc", - "...1", - "occurrenceMatrix", - "c.msmsWSspecs", - "mass.calc", - "updateObjectFromSlots")) - - +# Central import section + +#' @importFrom assertthat assert_that has_args +#' @importFrom Biobase isVersioned isCurrent classVersion<- classVersion +#' @importFrom ChemmineR smiles2sdf validSDF write.SDF +#' @importFrom data.table fread fwrite +#' @import digest +#' @importFrom dplyr rename_with select +#' @import glue +#' @import httr +#' @import httr2 +#' @import logger +#' @importFrom methods setGeneric setMethod +#' @import mzR +#' @import rcdk +#' @import Rcpp +#' @import readJDX +#' @import readr +#' @import rjson +#' @import S4Vectors +#' @importFrom stats lm loess median predict smooth.spline +#' @import stringr +#' @import tibble +#' @importFrom tidyselect everything +#' @importFrom utils URLencode capture.output data flush.console +#' @importFrom utils packageVersion read.csv read.csv2 setTxtProgressBar +#' @importFrom utils str txtProgressBar type.convert write.csv write.table +#' @importFrom utils globalVariables +#' @importFrom webchem cir_query +#' @import XML +#' @import yaml + + +.onLoad <- function(libname, pkgname) { + RMassBank.env <<- new.env() + RMassBank.env$ReadAnnotation <- FALSE + RMassBank.env$testnumber <- 1 + ## new variables + RMassBank.env$verbose.output <- FALSE + RMassBank.env$export.invalid <- FALSE + RMassBank.env$export.molfiles <- TRUE + RMassBank.env$strictMsMsSpectraSelection <- FALSE + + mb <- list() + attach(RMassBank.env) +} + +utils::globalVariables(c("cpdID", + "isotopes", + "mzCalc", + "...1", + "occurrenceMatrix", + "c.msmsWSspecs", + "mass.calc", + "updateObjectFromSlots")) + + diff --git a/man/CTS.externalIdSubset.Rd b/man/CTS.externalIdSubset.Rd index 5877a26..91b9b08 100644 --- a/man/CTS.externalIdSubset.Rd +++ b/man/CTS.externalIdSubset.Rd @@ -24,7 +24,7 @@ Select a subset of external IDs from a CTS record. # Return all CAS registry numbers stored for benzene. data <- getCtsRecord("UHOVQNZJYSORNB-UHFFFAOYSA-N") cas <- CTS.externalIdSubset(data, "CAS") -} +} } \author{ diff --git a/man/CTS.externalIdTypes.Rd b/man/CTS.externalIdTypes.Rd index a9a7513..bb99493 100644 --- a/man/CTS.externalIdTypes.Rd +++ b/man/CTS.externalIdTypes.Rd @@ -10,7 +10,7 @@ CTS.externalIdTypes(data) \item{data}{The complete CTS record as retrieved by \code{\link{getCtsRecord}}.} } \value{ -Returns an array of all database names for which there are external +Returns an array of all database names for which there are external identifiers stored in the record. } \description{ @@ -24,7 +24,7 @@ Find all available databases for a CTS record data <- getCTS("UHOVQNZJYSORNB-UHFFFAOYSA-N") databases <- CTS.externalIdTypes(data) -} +} } \author{ diff --git a/man/exportMassbank.Rd b/man/exportMassbank.Rd index 40ce169..bf00ea6 100755 --- a/man/exportMassbank.Rd +++ b/man/exportMassbank.Rd @@ -10,7 +10,7 @@ exportMassbank(compiled, molfile = NULL) \item{compiled}{\code{RmbSpectraSet} the spectra of one compound for which files should be exported} -\item{molfile}{A molfile from \code{\link{createMolfile}}; +\item{molfile}{A molfile from \code{\link{createMolfile}}; deprecated since molfiles are not used by MassBank anymore.} } \value{ diff --git a/man/flatten.Rd b/man/flatten.Rd index 2d60a06..f917255 100755 --- a/man/flatten.Rd +++ b/man/flatten.Rd @@ -5,7 +5,7 @@ \alias{readMbdata} \title{Flatten, or re-read, MassBank header blocks} \usage{ -flatten(mbdata) +flatten(mbdata) readMbdata(row) } diff --git a/man/gatherCCTE.Rd b/man/gatherCCTE.Rd index 6de7299..1826761 100644 --- a/man/gatherCCTE.Rd +++ b/man/gatherCCTE.Rd @@ -20,7 +20,7 @@ Returns a list with 5 slots: \code{smiles} The SMILES annotation of the structure } \description{ -Retrieves annotation data for a compound from the internet service US EPA CCTE +Retrieves annotation data for a compound from the internet service US EPA CCTE based on the inchikey generated by babel or Cactus } \details{ diff --git a/man/gatherData.Rd b/man/gatherData.Rd index 89e1a63..2e8992d 100755 --- a/man/gatherData.Rd +++ b/man/gatherData.Rd @@ -38,8 +38,8 @@ inserted empty and will be filled later on. } \references{ Chemical Translation Service: -\url{http://uranus.fiehnlab.ucdavis.edu:8080/cts/homePage} -cactus Chemical Identifier Resolver: +\url{http://uranus.fiehnlab.ucdavis.edu:8080/cts/homePage} +cactus Chemical Identifier Resolver: \url{http://cactus.nci.nih.gov/chemical/structure} MassBank record format: \url{http://www.massbank.jp/manuals/MassBankRecord_en.pdf} diff --git a/man/gatherDataBabel.Rd b/man/gatherDataBabel.Rd index 84737d0..d6e78d5 100644 --- a/man/gatherDataBabel.Rd +++ b/man/gatherDataBabel.Rd @@ -20,7 +20,7 @@ compound list. } \details{ Composes the "upper part" of a MassBank record filled with chemical data -about the compound: name, exact mass, structure, CAS no.. +about the compound: name, exact mass, structure, CAS no.. The instrument type is also written into this block (even if not strictly part of the chemical information). Additionally, index fields are added at the start of the record, which will be removed later: diff --git a/man/gatherDataUnknown.Rd b/man/gatherDataUnknown.Rd index 7f5903a..4c36eb5 100644 --- a/man/gatherDataUnknown.Rd +++ b/man/gatherDataUnknown.Rd @@ -9,7 +9,7 @@ gatherDataUnknown(id, mode, retrieval) \arguments{ \item{id}{The compound ID.} -\item{mode}{\code{"pH", "pNa", "pM", "pNH4", "mH", "mM", "mFA"} for different ions +\item{mode}{\code{"pH", "pNa", "pM", "pNH4", "mH", "mM", "mFA"} for different ions ([M+H]+, [M+Na]+, [M]+, [M+NH4]+, [M-H]-, [M]-, [M+FA]-).} \item{retrieval}{A value that determines whether the files should be handled either as "standard", @@ -25,7 +25,7 @@ Retrieves annotation data for an unknown compound by using basic information pre } \details{ Composes the "upper part" of a MassBank record filled with chemical data -about the compound: name, exact mass, structure, CAS no.. +about the compound: name, exact mass, structure, CAS no.. The instrument type is also written into this block (even if not strictly part of the chemical information). Additionally, index fields are added at the start of the record, which will be removed later: diff --git a/man/gatherPubChem.Rd b/man/gatherPubChem.Rd index ca21fc2..71c423c 100644 --- a/man/gatherPubChem.Rd +++ b/man/gatherPubChem.Rd @@ -17,7 +17,7 @@ Returns a list with 4 slots: \code{Chebi} The identification number of the chebi database } \description{ -Retrieves annotation data for a compound from the internet service Pubchem +Retrieves annotation data for a compound from the internet service Pubchem based on the inchikey generated by babel or Cactus } \details{ diff --git a/man/getCASRN.Rd b/man/getCASRN.Rd index 5d412a3..7b40630 100644 --- a/man/getCASRN.Rd +++ b/man/getCASRN.Rd @@ -28,7 +28,7 @@ getCASRN("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } \references{ -CCTE search: \url{https://api-ccte.epa.gov/docs} +CCTE search: \url{https://api-ccte.epa.gov/docs} CCTE REST: \url{https://api-ccte.epa.gov/docs} diff --git a/man/getCSID.Rd b/man/getCSID.Rd index c629808..472b4e7 100644 --- a/man/getCSID.Rd +++ b/man/getCSID.Rd @@ -2,31 +2,39 @@ % Please edit documentation in R/webAccess.R \name{getCSID} \alias{getCSID} -\title{Retrieve the Chemspider ID for a given compound} +\title{Search ChemSpider CSID} \usage{ -getCSID(query) +getCSID(key, identifier, api_key) } \arguments{ -\item{query}{The InChIKey of the compound} +\item{key}{ID to be converted} + +\item{identifier}{identifier (name, inchikey)} + +\item{api_key}{API key for ChemSpider (to be created on the developer site)} } \value{ -Returns the chemspide +The CSID (in string type) } \description{ -Given an InChIKey, this function queries the chemspider web API to retrieve -the Chemspider ID of he compound with that InChIkey. +Retrieves ChemSpider CSID from UK RSC for a search term. +} +\details{ +Requires a valid API key } \examples{ - \dontrun{ -# Return all CAS registry numbers stored for benzene. -data <- getCtsRecord("UHOVQNZJYSORNB-UHFFFAOYSA-N") -cas <- CTS.externalIdSubset(data, "CAS") -} +getDTXSID(key = "MKXZASYAUGDDCJ-NJAFHUGGSA-N", identifier = "InChIKey", api_key = "your RCS API key") +} +} +\references{ +ChemSpider search: \url{https://developer.rsc.org/api-reference#} +ChemSpider developer site: \url{https://developer.rsc.org} + +ChemSider REST: +\url{https://developer.rsc.org/api-reference#} } \author{ -Michele Stravs, Eawag - -Erik Mueller, UFZ +Tobias Schulze } diff --git a/man/getCtsRecord.Rd b/man/getCtsRecord.Rd index d5bde0b..4baf8ba 100755 --- a/man/getCtsRecord.Rd +++ b/man/getCtsRecord.Rd @@ -10,11 +10,11 @@ getCtsRecord(key) \item{key}{The InChI key.} } \value{ -Returns a list with all information from CTS: \code{inchikey, +Returns a list with all information from CTS: \code{inchikey, inchicode, formula, exactmass} contain single values. \code{synonyms} contains an unordered list of scored synonyms (\code{type, name, score}, where \code{type} indicates either a normal name or a specific IUPAC name, see below). - \code{externalIds} contains an unordered list of identifiers of the compound in + \code{externalIds} contains an unordered list of identifiers of the compound in various databases (\code{name, value}, where \code{name} is the database name and \code{value} the identifier in that database.) } diff --git a/man/getDTXCID.Rd b/man/getDTXCID.Rd index 64620c0..bd64429 100644 --- a/man/getDTXCID.Rd +++ b/man/getDTXCID.Rd @@ -27,7 +27,7 @@ getDTXCID("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } } \references{ -CCTE search: \url{https://api-ccte.epa.gov/docs} +CCTE search: \url{https://api-ccte.epa.gov/docs} CCTE REST: \url{https://api-ccte.epa.gov/docs} diff --git a/man/getDTXSID.Rd b/man/getDTXSID.Rd index cdd574e..f231a4f 100644 --- a/man/getDTXSID.Rd +++ b/man/getDTXSID.Rd @@ -27,7 +27,7 @@ getDTXSID("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } } \references{ -CCTE search: \url{https://api-ccte.epa.gov/docs} +CCTE search: \url{https://api-ccte.epa.gov/docs} CCTE REST: \url{https://api-ccte.epa.gov/docs} diff --git a/man/getDTXSMILES.Rd b/man/getDTXSMILES.Rd index c580c05..e0fa0c5 100644 --- a/man/getDTXSMILES.Rd +++ b/man/getDTXSMILES.Rd @@ -28,7 +28,7 @@ getDTXSMILES("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } \references{ -CCTE search: \url{https://api-ccte.epa.gov/docs} +CCTE search: \url{https://api-ccte.epa.gov/docs} CCTE REST: \url{https://api-ccte.epa.gov/docs} diff --git a/man/getPcId.Rd b/man/getPcId.Rd index 090f553..2a20b20 100755 --- a/man/getPcId.Rd +++ b/man/getPcId.Rd @@ -26,7 +26,7 @@ getPcId("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } \references{ -PubChem search: \url{http://pubchem.ncbi.nlm.nih.gov/} +PubChem search: \url{http://pubchem.ncbi.nlm.nih.gov/} Pubchem REST: \url{https://pubchem.ncbi.nlm.nih.gov/pug_rest/PUG_REST.html} diff --git a/man/getPrefName.Rd b/man/getPrefName.Rd index e340041..4ac9064 100644 --- a/man/getPrefName.Rd +++ b/man/getPrefName.Rd @@ -28,7 +28,7 @@ getPrefName("MKXZASYAUGDDCJ-NJAFHUGGSA-N") } \references{ -CCTE search: \url{https://api-ccte.epa.gov/docs} +CCTE search: \url{https://api-ccte.epa.gov/docs} CCTE REST: \url{https://api-ccte.epa.gov/docs} diff --git a/man/mbWorkflow.Rd b/man/mbWorkflow.Rd index f7a5524..681464c 100755 --- a/man/mbWorkflow.Rd +++ b/man/mbWorkflow.Rd @@ -21,10 +21,10 @@ mbWorkflow( which should then be manually inspected.} \item{gatherData}{A variable denoting whether to retrieve information using several online databases \code{gatherData= "online"} -or to use the local babel installation \code{gatherData= "babel"}. Note that babel is used either way, if a directory is given +or to use the local babel installation \code{gatherData= "babel"}. Note that babel is used either way, if a directory is given in the settings. This setting will be ignored if retrieval is set to "standard"} -\item{filter}{If \code{TRUE}, the peaks will be filtered according to the standard processing workflow in RMassBank - +\item{filter}{If \code{TRUE}, the peaks will be filtered according to the standard processing workflow in RMassBank - only the best formula for a peak is retained, and only peaks passing multiplicity filtering are retained. If FALSE, it is assumed that the user has already done filtering, and all peaks in the spectrum should be printed in the record (with or without formula.)} } @@ -69,7 +69,7 @@ Step 8: Create the list.tsv in the molfiles folder, which is required by MassBan mb <- newMbWorkspace(w) # w being a msmsWorkspace mb <- loadInfolists(mb, "D:/myInfolistPath") mb <- mbWorkflow(mb, steps=c(1:3), "newinfos.csv") - + } } \seealso{ diff --git a/man/toMassbank.Rd b/man/toMassbank.Rd index 9385ba4..d6f9706 100755 --- a/man/toMassbank.Rd +++ b/man/toMassbank.Rd @@ -16,7 +16,7 @@ toMassbank(o, ...) \item{o}{An object to convert to MassBank record format. This may be a single `RmbSpectrum2`, or a complete compound (an `RmbSpectraSet`),} -\item{...}{Parameters passed to the implementation, +\item{...}{Parameters passed to the implementation, in particular `addAnnotation`} \item{addAnnotation}{`logical`, whether to add peak annotations (putative formulas) to the record.} @@ -38,10 +38,10 @@ entries can be as follows: \itemize{ is written as - \code{CH\$EXACT_MASS: 329.1023} + \code{CH\$EXACT_MASS: 329.1023} \item A character array: - \code{'CH\$NAME' = c('2-Aminobenzimidazole', '1H-Benzimidazol-2-amine')} + \code{'CH\$NAME' = c('2-Aminobenzimidazole', '1H-Benzimidazol-2-amine')} is written as @@ -49,19 +49,19 @@ is written as \code{CH\$NAME: 1H-Benzimidazol-2-amine} -\item A named list of strings: +\item A named list of strings: - \code{'CH\$LINK' = list('CHEBI' = "27822", "KEGG" = "C10901")} + \code{'CH\$LINK' = list('CHEBI' = "27822", "KEGG" = "C10901")} -is written as +is written as \code{CH\$LINK: CHEBI 27822} -\code{CH\$LINK: KEGG C10901} +\code{CH\$LINK: KEGG C10901} \item A data frame (e.g. the peak table) is written as specified in the MassBank record format (Section 2.6.3): the column names are used as -headers for the first line, all data rows are printed space-separated. +headers for the first line, all data rows are printed space-separated. } } \note{ @@ -76,7 +76,7 @@ c('bla','blub')}. # Read just the compound info skeleton from the Internet for some compound ID id <- 35 mbdata <- gatherData(id) -#' # Export the mbdata blocks to line arrays +#' # Export the mbdata blocks to line arrays # (there is no spectrum information, just the compound info...) mbtext <- toMassbank(mbdata) }