Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ unpub
^Meta$
^cran-comments\.md$
^CRAN-RELEASE$
<<<<<<< HEAD
^\.github$
=======
^CRAN-SUBMISSION$
>>>>>>> 9bd8e8b6b425851ab94e90ad9e345eaa2d6e7c25
35 changes: 35 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
push:
pull_request:

name: R-CMD-check

jobs:
R-CMD-check:

runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- uses: r-lib/actions/setup-pandoc@v1

- name: Install libcurl4-openssl-dev
run: sudo apt install -qq libcurl4-openssl-dev

- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_bioc("snpStats")
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
shell: Rscript {0}

31 changes: 31 additions & 0 deletions .github/workflows/run_issue_6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
pull_request:

name: run_issue_6

jobs:
run_issue_6:

runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1

- name: Install libcurl4-openssl-dev
run: sudo apt install -qq libcurl4-openssl-dev

- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck", "rappdirs"))
remotes::install_deps(dependencies = TRUE)
remotes::install_github("OchoaLab/genio")
shell: Rscript {0}

- name: Run the code from https://github.com/OchoaLab/genio/issues/6
run: Rscript scripts/issue_6.R

82 changes: 82 additions & 0 deletions scripts/issue_6.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Code from https://github.com/OchoaLab/genio/issues/6

################################################################################
#
# 1. `write_bed` works as expected, from documentation example code
#
################################################################################
file_out <- tempfile('delete-me-example', fileext = '.bed') # will also work without extension
X <- rbinom(10, 2, 0.5)
X[sample(10, 3)] <- NA
X <- matrix(X, nrow = 5, ncol = 2)
genio::write_bed(file_out, X) # WORKS

################################################################################
#
# 2. `write_bed` works as expected, when saving
# * in a normalized path
# * in a sub-folder that exists
#
################################################################################
file_out <- file.path(
rappdirs::user_cache_dir(appname = "my_r_package_name"),
"sub_folder_2", "my_filename"
)
dir.create(dirname(file_out), recursive = TRUE)
file_out <- normalizePath(file_out, mustWork = FALSE)
#
# On my computer:
# file_out == "/home/richel/.cache/my_r_package_name/sub_folder/my_filename"
#
X <- rbinom(10, 2, 0.5)
X[sample(10, 3)] <- NA
X <- matrix(X, nrow = 5, ncol = 2)
genio::write_bed(file_out, X) # WORKS

################################################################################
#
# 3. `write_bed` crashes ruthlessly, when saving
# * in a normalized path
# * in a sub-folder that does not exist
#
################################################################################
file_out <- file.path(
rappdirs::user_cache_dir(appname = "my_r_package_name"),
"sub_folder_3", "my_filename"
)
file_out <- normalizePath(file_out, mustWork = FALSE)
#
# On my computer:
# file_out == "/home/richel/.cache/my_r_package_name/sub_folder/my_filename"
#
X <- rbinom(10, 2, 0.5)
X[sample(10, 3)] <- NA
X <- matrix(X, nrow = 5, ncol = 2)

# The original problem:
#
# genio::write_bed(file_out, X) # CAUSES ABORT
#
# This is fixed now: it is handled with an R error message
# (i.e. no system crash)
testthat::expect_error(
genio::write_bed(file_out, X)
)

################################################################################
#
# 4. `write_bed` crashes ruthlessly, when saving
# * in an un-normalized path
# * in a sub-folder that does exist
#
################################################################################
file_out <- file.path(
rappdirs::user_cache_dir(appname = "my_r_package_name"),
"sub_folder_4", "my_filename"
)
dir.create(dirname(file_out), recursive = TRUE)
testthat::expect_equal(file_out, "~/.cache/my_r_package_name/sub_folder_4/my_filename")
X <- rbinom(10, 2, 0.5)
X[sample(10, 3)] <- NA
X <- matrix(X, nrow = 5, ncol = 2)
genio::write_bed(file_out, X) # CAUSES ABORT