richelbilderbeek / mhcnuggetsr

Package to call MHCnuggets from R, to predict MHC-I and MHC-II epitopes
GNU General Public License v3.0
4 stars 1 forks source link

FileNotFoundError: [Errno 2] No such file or directory: '~/.cache/mhcnuggets_35b8225bc9d4.fasta' #13

Open limbo1996 opened 3 years ago

limbo1996 commented 3 years ago

Describe the bug When I run the example code:

if (is_mhcnuggets_installed()) {

  peptides <- c("AIAACAMLLV", "ALVCYIVMPV", "ALEPRKEIDV")
  mhc_1_haplotype <- "HLA-A02:01"

  mhcnuggets_options <- create_mhcnuggets_options(
    mhc = mhc_1_haplotype
  )

  predict_ic50(
    peptides = peptides,
    mhcnuggets_options = mhcnuggets_options
  )
}

It returns

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  FileNotFoundError: [Errno 2] No such file or directory: '~/.cache/mhcnuggets_35b8225bc9d4.fasta'

I think because create_temp_peptides_path(), return a relative paths. So I change the option peptides_path

test  <- predict_ic50(peptides = "AIAACAMLLV", mhcnuggets_options = mhcnuggets_options, peptides_path="/public/slst/home/wangxuan1/tmp/test.fasta")

But now I get

Predicting for 1 peptides
Number of peptides skipped/total due to length 0 / 0
Building model
Closest allele found HLA-A02:01
BA_to_HLAp model found, predicting with BA_to_HLAp model...
Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AttributeError: 'str' object has no attribute 'decode'

Detailed traceback:
  File "/slst/home/wangxuan1/miniconda3/envs/mhcnuggets/lib/python3.7/site-packages/mhcnuggets/src/predict.py", line 69, in predict
    model.load_weights(os.path.join(MHCNUGGETS_HOME,model_weights_path,predictor_mhc+'_BA_to_HLAp.h5'))
  File "/slst/home/wangxuan1/miniconda3/envs/mhcnuggets/lib/python3.7/site-packages/keras/engine/saving.py", line 492, in load_wrapper
    return load_function(*args, **kwargs)
  File "/slst/home/wangxuan1/miniconda3/envs/mhcnuggets/lib/python3.7/site-packages/keras/engine/network.py", line 1230, in load_weights
    f, self.layers, reshape=reshape)
  File "/slst/home/wangxuan1/miniconda3/envs/mhcnuggets/lib/python3.7/site-packages/keras/engine/saving.py", line 1183, in load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')

report

***************
* mhcnuggetsr *
***************
OS: unix
Python location: /slst/home/wangxuan1/miniconda3/envs/mhcnuggets/bin/python3
Is pip installed: TRUE
pip version: 21.2.1
Python NumPy available: TRUE
Python mhcnuggets available: TRUE
**************
* MHCnuggets *
**************
Is MHCnuggets installed: TRUE
MHCnuggets version: 2.3.3
***************
* sessionInfo *
***************
R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /slst/home/wangxuan1/miniconda3/envs/mhcnuggets/lib/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] testthat_3.0.4  mhcnuggetsr_1.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7      knitr_1.33      rematch2_2.1.2  magrittr_2.0.1 
 [5] rappdirs_0.3.3  lattice_0.20-44 R6_2.5.0        rlang_0.4.11   
 [9] fansi_0.5.0     highr_0.9       stringr_1.4.0   tools_3.6.1    
[13] grid_3.6.1      xfun_0.24       waldo_0.2.5     png_0.1-7      
[17] utf8_1.2.2      ellipsis_0.3.2  tibble_3.1.3    lifecycle_1.0.0
[21] crayon_1.4.1    Matrix_1.3-4    vctrs_0.3.8     glue_1.4.2     
[25] stringi_1.7.3   compiler_3.6.1  diffobj_0.3.4   pillar_1.6.1   
[29] reticulate_1.20 jsonlite_1.7.2  pkgconfig_2.0.3
richelbilderbeek commented 3 years ago

Hi @limbo1996, thanks for this well-done report! I'll try to reproduce it now.

I agree, both these one-liners fails, it appears something changed upstream ...

mhcnuggetsr::predict_ic50(
  peptides = "AIAACAMLLV", 
  mhcnuggets_options = create_mhcnuggets_options(
    mhc = "HLA-A02:01"
  )
)

mhcnuggetsr::predict_ic50(
  peptides = "AIAACAMLLV", 
  mhcnuggets_options = create_mhcnuggets_options(
    mhc = "HLA-A02:01"
  ),
  peptides_path = "temp.fasta"
)
richelbilderbeek commented 3 years ago

Boy, the repo is in pretty bad shape. I will take a look tonight, else in the weekend.

@limbo1996: would you volunteer to confirm I did my job well after I did this?

richelbilderbeek commented 3 years ago

Note to self: https://github.com/richelbilderbeek/mhcnuggetsr/runs/3201894420?check_suite_focus=true#step:8:180 shows:

── Error (test-mhcnuggetsr_self_test.R:3:5): default use ───────────────────────
Error: Error: AttributeError: module 'mhcnuggets.src' has no attribute 'predict'

to me this seems like a big hint that the backend has changed.

richelbilderbeek commented 3 years ago

Note to self, this is what I get on my local computer, where mhcnuggetsr works fine:

> mhcnuggetsr::mhcnuggetsr_report()
***************
* mhcnuggetsr *
***************
OS: unix
Python location: /home/richel/.local/share/r-miniconda/envs/r-reticulate/bin/python
Is pip installed: TRUE
pip version: 21.2.1
Python NumPy available: TRUE
Python mhcnuggets available: TRUE
**************
* MHCnuggets *
**************
Is MHCnuggets installed: TRUE
MHCnuggets version: 2.3.3
****************
* session info *
****************
─ Session info ────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.1.0 (2021-05-18)
 os       Ubuntu 20.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Amsterdam            
 date     2021-07-30                  

─ Packages ────────────────────────────────────────────────────────────────────────────────────────
 package     * version date       lib source        
 cachem        1.0.5   2021-05-15 [1] CRAN (R 4.1.0)
 callr         3.7.0   2021-04-20 [1] CRAN (R 4.1.0)
 cli           3.0.1   2021-07-17 [1] CRAN (R 4.1.0)
 crayon        1.4.1   2021-02-08 [1] CRAN (R 4.1.0)
 desc          1.3.0   2021-03-05 [1] CRAN (R 4.1.0)
 devtools      2.4.2   2021-06-07 [1] CRAN (R 4.1.0)
 diffobj       0.3.4   2021-03-22 [1] CRAN (R 4.1.0)
 digest        0.6.27  2020-10-24 [1] CRAN (R 4.1.0)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
 evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.0)
 fansi         0.5.0   2021-05-25 [1] CRAN (R 4.1.0)
 fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
 fs            1.5.0   2020-07-31 [1] CRAN (R 4.1.0)
 glue          1.4.2   2020-08-27 [1] CRAN (R 4.1.0)
 highr         0.9     2021-04-16 [1] CRAN (R 4.1.0)
 htmltools     0.5.1.1 2021-01-22 [1] CRAN (R 4.1.0)
 jsonlite      1.7.2   2020-12-09 [1] CRAN (R 4.1.0)
 knitr         1.33    2021-04-24 [1] CRAN (R 4.1.0)
 lattice       0.20-44 2021-05-02 [4] CRAN (R 4.1.0)
 lifecycle     1.0.0   2021-02-15 [1] CRAN (R 4.1.0)
 magrittr      2.0.1   2020-11-17 [1] CRAN (R 4.1.0)
 Matrix        1.3-4   2021-06-01 [4] CRAN (R 4.1.0)
 memoise       2.0.0   2021-01-26 [1] CRAN (R 4.1.0)
 mhcnuggetsr   1.2     2021-07-30 [1] local         
 netmhcpan     1.3.1   2021-07-29 [1] local         
 pillar        1.6.2   2021-07-29 [1] CRAN (R 4.1.0)
 pkgbuild      1.2.0   2020-12-15 [1] CRAN (R 4.1.0)
 pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
 pkgload       1.2.1   2021-04-06 [1] CRAN (R 4.1.0)
 png           0.1-7   2013-12-03 [1] CRAN (R 4.1.0)
 prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.1.0)
 processx      3.5.2   2021-04-30 [1] CRAN (R 4.1.0)
 ps            1.6.0   2021-02-28 [1] CRAN (R 4.1.0)
 purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.0)
 R6            2.5.0   2020-10-28 [1] CRAN (R 4.1.0)
 rappdirs      0.3.3   2021-01-31 [1] CRAN (R 4.1.0)
 Rcpp          1.0.7   2021-07-07 [1] CRAN (R 4.1.0)
 rematch2      2.1.2   2020-05-01 [1] CRAN (R 4.1.0)
 remotes       2.4.0   2021-06-02 [1] CRAN (R 4.1.0)
 reticulate    1.20    2021-05-03 [1] CRAN (R 4.1.0)
 rlang         0.4.11  2021-04-30 [1] CRAN (R 4.1.0)
 rmarkdown     2.9     2021-06-15 [1] CRAN (R 4.1.0)
 rprojroot     2.0.2   2020-11-15 [1] CRAN (R 4.1.0)
 sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 4.1.0)
 stringi       1.7.3   2021-07-16 [1] CRAN (R 4.1.0)
 stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.0)
 testit        0.13    2021-04-14 [1] CRAN (R 4.1.0)
 testthat      3.0.4   2021-07-01 [1] CRAN (R 4.1.0)
 tibble        3.1.3   2021-07-23 [1] CRAN (R 4.1.0)
 usethis       2.0.1   2021-02-10 [1] CRAN (R 4.1.0)
 utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
 vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.0)
 waldo         0.2.5   2021-03-08 [1] CRAN (R 4.1.0)
 withr         2.4.2   2021-04-18 [1] CRAN (R 4.1.0)
 xfun          0.24    2021-06-15 [1] CRAN (R 4.1.0)
 yaml          2.2.1   2020-02-01 [1] CRAN (R 4.1.0)

[1] /home/richel/R/x86_64-pc-linux-gnu-library/4.1
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library
richelbilderbeek commented 3 years ago

Note to self: I can reproduce the error by deleting the installed conda libs.

Below is the info after a fresh install. It does not matter, as it does not show the conda Python package versions.

> mhcnuggetsr::mhcnuggetsr_report()
***************
* mhcnuggetsr *
***************
OS: unix
Python location: /home/richel/.local/share/r-miniconda/envs/r-reticulate/bin/python
Is pip installed: TRUE
pip version: 21.2.1
Python NumPy available: TRUE
Python mhcnuggets available: TRUE
**************
* MHCnuggets *
**************
Is MHCnuggets installed: TRUE
MHCnuggets version: 2.3.3
****************
* session info *
****************
─ Session info ────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.1.0 (2021-05-18)
 os       Ubuntu 20.04.2 LTS          
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Amsterdam            
 date     2021-07-30                  

─ Packages ────────────────────────────────────────────────────────────────────────────────────────
 ! package            * version date       lib source                                              
   cachem               1.0.5   2021-05-15 [1] CRAN (R 4.1.0)                                      
   callr                3.7.0   2021-04-20 [1] CRAN (R 4.1.0)                                      
   cli                  3.0.1   2021-07-17 [1] CRAN (R 4.1.0)                                      
   crayon               1.4.1   2021-02-08 [1] CRAN (R 4.1.0)                                      
   desc                 1.3.0   2021-03-05 [1] CRAN (R 4.1.0)                                      
   devtools             2.4.2   2021-06-07 [1] CRAN (R 4.1.0)                                      
   diffobj              0.3.4   2021-03-22 [1] CRAN (R 4.1.0)                                      
   ellipsis             0.3.2   2021-04-29 [1] CRAN (R 4.1.0)                                      
   fansi                0.5.0   2021-05-25 [1] CRAN (R 4.1.0)                                      
   fastmap              1.1.0   2021-01-25 [1] CRAN (R 4.1.0)                                      
   fs                   1.5.0   2020-07-31 [1] CRAN (R 4.1.0)                                      
   glue                 1.4.2   2020-08-27 [1] CRAN (R 4.1.0)                                      
   highr                0.9     2021-04-16 [1] CRAN (R 4.1.0)                                      
   jsonlite             1.7.2   2020-12-09 [1] CRAN (R 4.1.0)                                      
   knitr                1.33    2021-04-24 [1] CRAN (R 4.1.0)                                      
   lattice              0.20-44 2021-05-02 [4] CRAN (R 4.1.0)                                      
   lifecycle            1.0.0   2021-02-15 [1] CRAN (R 4.1.0)                                      
   magrittr             2.0.1   2020-11-17 [1] CRAN (R 4.1.0)                                      
   Matrix               1.3-4   2021-06-01 [4] CRAN (R 4.1.0)                                      
   memoise              2.0.0   2021-01-26 [1] CRAN (R 4.1.0)                                      
 P mhcnuggetsr        * 1.2     2021-07-30 [?] local                                               
   mhcnuggetsrinstall   0.1     2021-07-30 [1] Github (richelbilderbeek/mhcnuggetsrinstall@5ad55eb)
   pillar               1.6.2   2021-07-29 [1] CRAN (R 4.1.0)                                      
   pkgbuild             1.2.0   2020-12-15 [1] CRAN (R 4.1.0)                                      
   pkgconfig            2.0.3   2019-09-22 [1] CRAN (R 4.1.0)                                      
   pkgload              1.2.1   2021-04-06 [1] CRAN (R 4.1.0)                                      
   png                  0.1-7   2013-12-03 [1] CRAN (R 4.1.0)                                      
   prettyunits          1.1.1   2020-01-24 [1] CRAN (R 4.1.0)                                      
   processx             3.5.2   2021-04-30 [1] CRAN (R 4.1.0)                                      
   ps                   1.6.0   2021-02-28 [1] CRAN (R 4.1.0)                                      
   purrr                0.3.4   2020-04-17 [1] CRAN (R 4.1.0)                                      
   R6                   2.5.0   2020-10-28 [1] CRAN (R 4.1.0)                                      
   rappdirs             0.3.3   2021-01-31 [1] CRAN (R 4.1.0)                                      
   Rcpp                 1.0.7   2021-07-07 [1] CRAN (R 4.1.0)                                      
   rematch2             2.1.2   2020-05-01 [1] CRAN (R 4.1.0)                                      
   remotes              2.4.0   2021-06-02 [1] CRAN (R 4.1.0)                                      
   reticulate           1.20    2021-05-03 [1] CRAN (R 4.1.0)                                      
   rlang                0.4.11  2021-04-30 [1] CRAN (R 4.1.0)                                      
   rprojroot            2.0.2   2020-11-15 [1] CRAN (R 4.1.0)                                      
   rstudioapi           0.13    2020-11-12 [1] CRAN (R 4.1.0)                                      
   sessioninfo          1.1.1   2018-11-05 [1] CRAN (R 4.1.0)                                      
   stringi              1.7.3   2021-07-16 [1] CRAN (R 4.1.0)                                      
   stringr              1.4.0   2019-02-10 [1] CRAN (R 4.1.0)                                      
   testthat           * 3.0.4   2021-07-01 [1] CRAN (R 4.1.0)                                      
   tibble               3.1.3   2021-07-23 [1] CRAN (R 4.1.0)                                      
   usethis              2.0.1   2021-02-10 [1] CRAN (R 4.1.0)                                      
   utf8                 1.2.2   2021-07-24 [1] CRAN (R 4.1.0)                                      
   vctrs                0.3.8   2021-04-29 [1] CRAN (R 4.1.0)                                      
   waldo                0.2.5   2021-03-08 [1] CRAN (R 4.1.0)                                      
   withr                2.4.2   2021-04-18 [1] CRAN (R 4.1.0)                                      
   xfun                 0.24    2021-06-15 [1] CRAN (R 4.1.0)                                      

[1] /home/richel/R/x86_64-pc-linux-gnu-library/4.1
[2] /usr/local/lib/R/site-library
[3] /usr/lib/R/site-library
[4] /usr/lib/R/library

 P ── Loaded and on-disk path mismatch.
richelbilderbeek commented 3 years ago

Hmmm, reticulate does not give the results anymore from tooltip:

Screenshot from 2021-07-31 16-34-53

Also adding the path argument here does not help ....

richelbilderbeek commented 3 years ago

I cannot get reticulate to import mhcnuggets correctly :-/

Screenshot from 2021-07-31 16-43-03

richelbilderbeek commented 3 years ago

Is it normal that python does not find the ´predict´ function of ´mhcnuggets´ ?

Screenshot from 2021-07-31 16-46-44

richelbilderbeek commented 3 years ago

Note that the Appveyor build still works correctly! It must be some upstream thing!

Screenshot from 2021-07-31 17-24-45

richelbilderbeek commented 3 years ago

Hi @limbo1996, thanks for your bug report. In summary, mhcnuggetsr is broken due to an upstream change, either in the reticulate R package, the mhcnuggets Python package or something else. This can be concluded from that mhcnuggetsr stil builds fine op AppVeyor, but not on GitHub Actions.

If you know any people that could fix this, I could use that help. Up until then, this package is officially broken :-/