read.dcd(big = TRUE) Error

Issue #793 new
Brady created an issue

I have been getting errors trying to read in using the read.dcd() command. It works when reading in smaller trajectory files, but if trying to read in a large trajectory with big = TRUE I get an error.

When troubleshooting, attempting to replicate your examples from the documentation:

##-- Read cell parameters from example trajectory file
trtfile <- system.file("examples/hivp.dcd", package="bio3d")
trj <- read.dcd(trtfile, cell = TRUE)
##-- Read coordinates from example trajectory file
trj <- read.dcd(trtfile)

Example works fine, but if I try to use big = TRUE in the example I get the same error:

trj <- read.dcd(trtfile, big = TRUE)

Error:

Error in to.return[i, ] <- dcd.frame(trj, head, cell) : 
  object of type 'S4' is not subsettable
In addition: Warning messages:
1: In readChar(trj, 80) : truncating string with embedded nuls
2: In readChar(trj, 80) : truncating string with embedded nuls

Seems to be a problem interacting with {bigmemory} matrices. I've tried on macOS, Windows and Linux and they are all producing the same error when big = TRUE.

SessionInfo:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] bio3d_2.4-1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6          bigmemory.sri_0.1.3 knitr_1.31          magrittr_2.0.1     
 [5] tidyselect_1.1.0    munsell_0.5.0       colorspace_2.0-0    R6_2.5.0           
 [9] rlang_0.4.10        bigmemory_4.5.36    fansi_0.4.2         dplyr_1.0.4        
[13] tools_4.0.2         parallel_4.0.2      grid_4.0.2          gtable_0.3.0       
[17] xfun_0.20           cli_2.3.0           DBI_1.1.1           dbplyr_2.1.0       
[21] htmltools_0.5.1.1   ellipsis_0.3.1      yaml_2.2.1          assertthat_0.2.1   
[25] digest_0.6.27       tibble_3.0.6        lifecycle_0.2.0     crayon_1.4.0       
[29] purrr_0.3.4         ggplot2_3.3.3       vctrs_0.3.6         glue_1.4.2         
[33] compiler_4.0.2      pillar_1.4.7        generics_0.1.0      scales_1.1.1       
[37] pkgconfig_2.0.3

Comments (3)

  1. Xinqiu Yao

    Hi,

    Thanks for catching it up! big=TRUE is not very often used and so hasn’t been tested for a long time. We will fix it asap.

    One more thing to note is that the bigmemory’s big.matrix is not fully supported yet. Even if you can read the traject as a big.matrix, you may still not be able to do some featured calculations because they assume a regular R matrix. So, if your trajectory is really big and you want all the features, you may think to reduce the file size by, e.g., skipping some frames, and read it in the regular way.

    Hope it may help.

  2. Brady reporter

    Thanks! I will have a go with the updated function, and see if I run into any problems. Do you have a list of the functions that don’t support big.matrix, or will I just see as I go along?

  3. Log in to comment