# demo

    library(knitr)
    library(mhcnuggetsr)
    library(testthat)

For this vignette, we use the same example as the MHCnuggets Python notebooks.

Get the path to the testing peptides, and show them:

    if (is_mhcnuggets_installed()) {
      peptides_path <- get_example_filename("test_peptides.peps")
      expect_true(file.exists(peptides_path))
      readLines(peptides_path, warn = FALSE)
    }

Pick an MHC-I haplotype:

    if (is_mhcnuggets_installed()) {
      mhc_1_haplotype <- "HLA-A02:01"
      expect_true(mhc_1_haplotype %in% get_trained_mhc_1_haplotypes())
    }

Predict:

    if (is_mhcnuggets_installed()) {
      mhcnuggets_options <- create_mhcnuggets_options(
        mhc = mhc_1_haplotype
      )
      df <- predict_ic50_from_file(
        peptides_path = peptides_path,
        mhcnuggets_options = mhcnuggets_options
      )
      kable(df)
    }

Predict:

    if (is_mhcnuggets_installed()) {
      mhcnuggets_options <- create_mhcnuggets_options(
        mhc = mhc_1_haplotype,
        ba_models = TRUE
      )
      df <- predict_ic50_from_file(
        peptides_path = peptides_path,
        mhcnuggets_options = mhcnuggets_options
      )
      kable(df)
    }

Use MCH-II haplotype:

    if (is_mhcnuggets_installed()) {
      mhc_2_haplotype <- "HLA-DRB101:01"
      expect_true(mhc_2_haplotype %in% get_trained_mhc_2_haplotypes())
    }

Predict:

    if (is_mhcnuggets_installed()) {
      mhcnuggets_options <- create_mhcnuggets_options(
        mhc = mhc_2_haplotype
      )
      df <- predict_ic50_from_file(
        peptides_path = peptides_path,
        mhcnuggets_options = mhcnuggets_options
      )
      kable(df)
    }

Use another MHC-I haplotype. In this case, MHCnuggets has not been trained upon it, but it is a valid supertype:

    if (is_mhcnuggets_installed()) {
      mhc_1_haplotype <- "HLA-A02:60"
      expect_false(mhc_1_haplotype %in% get_trained_mhc_1_haplotypes())
    }

Predict:

    if (is_mhcnuggets_installed()) {
      mhcnuggets_options <- create_mhcnuggets_options(
        mhc_class = "I",
        mhc = mhc_1_haplotype
      )
      df <- predict_ic50_from_file(
        peptides_path = peptides_path,
        mhcnuggets_options = mhcnuggets_options
      )
      kable(df)
    }

## Appendix

### All example files

    if (is_mhcnuggets_installed()) {
      basename(get_example_filenames())
    }

### All MHC-I haplotypes

These are the MHC-I haplotypes that have a trained model.

    if (is_mhcnuggets_installed()) {
      cat(get_trained_mhc_1_haplotypes())
    }

### All MHC-II haplotypes

These are the MHC-II haplotypes that have a trained model.

    if (is_mhcnuggets_installed()) {
      cat(get_trained_mhc_2_haplotypes())
    }

### Session info

    mhcnuggetsr_report()
    #> ***************
    #> * mhcnuggetsr *
    #> ***************
    #> OS: unix
    #> Python location: /usr/bin/python3
    #> Is pip installed: TRUE
    #> pip version: 20.0.2
    #> Python NumPy available: TRUE
    #> Python mhcnuggets available: TRUE
    #> **************
    #> * MHCnuggets *
    #> **************
    #> Is MHCnuggets installed: FALSE
    #> Tip: when working on the Groninger Peregrine computer cluster,
    #> type:
    #>
    #> ~/.local/share/r-miniconda/envs/r-reticulate/bin/python -m pip  install mhcnuggets
    #> ***************
    #> * sessionInfo *
    #> ***************
    #> R version 3.6.3 (2020-02-29)
    #> Platform: x86_64-pc-linux-gnu (64-bit)
    #> Running under: Ubuntu 20.04.1 LTS
    #>
    #> Matrix products: default
    #> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
    #> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
    #>
    #> locale:
    #>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    #>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
    #>  [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_2.3.2  mhcnuggetsr_1.1 knitr_1.30
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] Rcpp_1.0.5           magrittr_1.5         rappdirs_0.3.1
    #>  [4] lattice_0.20-40      R6_2.4.1             rlang_0.4.8
    #>  [7] highr_0.8            stringr_1.4.0        tools_3.6.3
    #> [10] grid_3.6.3           xfun_0.18            htmltools_0.5.0.9001
    #> [13] ellipsis_0.3.1       yaml_2.2.1           digest_0.6.27
    #> [16] tibble_3.0.4         lifecycle_0.2.0      crayon_1.3.4
    #> [19] Matrix_1.2-18        vctrs_0.3.4          evaluate_0.14
    #> [22] rmarkdown_2.4        stringi_1.5.3        compiler_3.6.3
    #> [25] pillar_1.4.6         reticulate_1.16      jsonlite_1.7.1
    #> [28] pkgconfig_2.0.3