From 25e849254e457b0de632ee8824c274af50b52ae2 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Wed, 15 Mar 2023 15:06:49 +0100 Subject: [PATCH 01/19] fix CI/CD --- .Rbuildignore | 3 ++ DESCRIPTION | 2 +- NAMESPACE | 6 ++- R/build_mz_peptides.R | 19 ++++------ R/d_ppm.R | 11 +++--- R/get_combination_compounds.R | 19 +++++++--- ...nt_oligopeptides.R => get_oligopeptides.R} | 33 +++++++++------- R/match_mz_obs.R | 22 ++++++----- R/mz_matching.R | 38 ------------------- ..._vector_np1.R => oligopeptides_building.R} | 14 ++++--- README.md | 2 +- 11 files changed, 76 insertions(+), 93 deletions(-) rename R/{get_arrangement_oligopeptides.R => get_oligopeptides.R} (58%) delete mode 100644 R/mz_matching.R rename R/{mass_oligo_vector_np1.R => oligopeptides_building.R} (84%) diff --git a/.Rbuildignore b/.Rbuildignore index fa24b7e..9c0b4f0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,6 @@ devel.md$ ^.*\.Rproj$ ^\.circleci\.yml$ ^LICENSE\.md$ +.circleci +exampleOligopeptides* +Data \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 1517f88..ce1e1c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: oligopeptidesMatching Title: Library of functions for in silico construction and detection of oligopeptides -Description: In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree +Description: In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree. Version: 0.0.1 Authors@R: c( person(given = "Kevin", diff --git a/NAMESPACE b/NAMESPACE index 8b3080e..cb007cb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,10 @@ export(build_mz_peptides) export(d_ppm) +export(get_combination_compounds) export(get_oligopeptides) -export(mz_matching) +export(match_mz_obs) export(oligopeptides_building) +importFrom(dplyr,"%>%") +importFrom(dplyr,filter) +importFrom(dplyr,mutate) diff --git a/R/build_mz_peptides.R b/R/build_mz_peptides.R index f9daacb..35a4143 100644 --- a/R/build_mz_peptides.R +++ b/R/build_mz_peptides.R @@ -1,23 +1,20 @@ -#' Builds an informative matrix of Oligopeptides mapping to Mass Spectrometry output +#' Builds an informative matrix of Oligopeptides mapping to +#' Mass Spectrometry output #' #' Builds a matrix containing : #' - Oligomerization Degree #' - Id (Combinaison of Amino Acid names) #' - Mz (ionized mass) -#' - [M - X ionization[1]] negative mode ionization -#' - [M + X ionization[1]] positive mode ionization -#' - [M - X ionization[2]] negative mode ionization -#' - [M + X ionization[2]] positive mode ionization -#' - ... -#' -#' #' @param peptide list of oligopeptide, Named num (column with names) #' @param oligomerization_degree integer : oligomerization degree #' @param ionization : list of ionization -#' @return a data.frame containing OD, Id , Mz , ([M - Xionization ], [M + Xionization])+ . +#' @return a data.frame containing OD, Id , Mz , +#' M + Xionization, M - Xionization #' @export -#' @examples -#' build_mz_peptides(stats::setNames(c(160.0848,192.0569),c("A_A","A_C")), 2, stats::setNames(c(1.007825),c("H"))) +#' @examples +#' build_mz_peptides( +#' stats::setNames(c(160.0848,192.0569),c("A_A","A_C")), 2, +#' stats::setNames(c(1.007825),c("H"))) build_mz_peptides <- function(peptide, oligomerization_degree, ionization){ diff --git a/R/d_ppm.R b/R/d_ppm.R index 0a534f5..b072ca2 100644 --- a/R/d_ppm.R +++ b/R/d_ppm.R @@ -2,12 +2,13 @@ #' #' @description Calculate the δppm between an observed mz and a theorical one #' @param mz_obs is the observed mz of the metabolomic study -#' @param mz_theoric is the theorical mz (calculated by get_arrangement_oligopeptides and or get_combination_compounds) -#' @return the δppm of the difference between the mz observed and a theorical one +#' @param mz_theoric theorical mz (calculated by get_arrangement_oligopeptides +#' and or get_combination_compounds) +#' @return δppm of the difference between the mz observed and a theorical one #' @export -#' @examples for the glucose in negative ionization mode: d_ppm(179.0564, 179.0561) -d_ppm <- function(mz_obs, mz_theoric){ - if(mz_theoric==0){ +#' @examples d_ppm(179.0564, 179.0561) +d_ppm <- function(mz_obs, mz_theoric) { + if (mz_theoric == 0) { return(0) } ppm_error <- abs(((mz_obs - mz_theoric) / mz_theoric) * 10^6) diff --git a/R/get_combination_compounds.R b/R/get_combination_compounds.R index f7ce31b..7354dfc 100644 --- a/R/get_combination_compounds.R +++ b/R/get_combination_compounds.R @@ -1,16 +1,24 @@ -# compounds_1, compounds_2 = R column with a name (Named num) +#' get_combination_compounds +#' +#' compounds_1, compounds_2 = R column with a name (Named num) +#' @param compounds_1 compounds_1 +#' @param compounds_2 compounds_2 +#' @param chemical_reaction chemical_reaction +#' @param ionization ionization +#' @return δppm of the difference between the mz observed and a theorical one +#' @export get_combination_compounds <- function(compounds_1, compounds_2, chemical_reaction, - ionization){ + ionization) { -n = length(compounds_1) -m = length(compounds_2) +n <- length(compounds_1) +m <- length(compounds_2) combined_compounds_names <- vector("character", m*n) combined_compounds_mass <- vector("numeric", m*n) -k = 1 +k <- 1 for (i in 1:n){ for (j in 1:m){ @@ -24,7 +32,6 @@ combined_compounds <- (stats::setNames(combined_compounds_mass,combined_compound combined_compounds <- combined_compounds[unique(names(combined_compounds))] df <- as.data.frame(combined_compounds) -# df[order(df$combined_compounds_mass)] return(df) } diff --git a/R/get_arrangement_oligopeptides.R b/R/get_oligopeptides.R similarity index 58% rename from R/get_arrangement_oligopeptides.R rename to R/get_oligopeptides.R index 36a687a..5ee20cf 100644 --- a/R/get_arrangement_oligopeptides.R +++ b/R/get_oligopeptides.R @@ -1,24 +1,28 @@ -#' Builds an informative and complete matrix of Oligopeptides mapping to Mass Spectrometry output -#' +#' Builds an informative and complete matrix of Oligopeptides +#' mapping to Mass Spectrometry output +#' #' Builds a matrix containing : #' - Oligomerization Degree #' - Id (Combinaison of Amino Acid names) #' - Mz (ionized mass) -#' - [M - X ionization[1]] negative mode ionization -#' - [M + X ionization[1]] positive mode ionization -#' - [M - X ionization[2]] negative mode ionization -#' - [M + X ionization[2]] positive mode ionization +#' - M - X ionization 1 negative mode ionization +#' - M + X ionization 1 positive mode ionization +#' - M - X ionization 2 negative mode ionization +#' - M + X ionization 2 positive mode ionization #' - ... -#' -#' +#' #' @param aminoacids list of amino acids. -#' @param chemical_reaction reaction linking the combination of oligopepid and amino acids. +#' @param chemical_reaction reaction linking the combination of +#' oligopepid and amino acids. #' @param ionization list of ionization -#' @param oligomerization_degree integer : oligomerization degree -#' @return matrix containing OD, Id , Mz , ([M - Xionization ], [M + Xionization])+ . +#' @param oligomerization_degree integer : oligomerization degree +#' @return matrix containing OD, Id , Mz ,M - Xionization,M + Xionization . #' @export -#' @examples -#' get_oligopeptides(aminoacids = stats::setNames(c(89.047679),c("A")),chemical_reaction = 18.010565,ionization = stats::setNames(c(1.007825),c("H")),oligomerization_degree = 4) +#' @examples +#' get_oligopeptides(aminoacids = stats::setNames(c(89.047679),c("A")), +#' chemical_reaction = 18.010565, +#' ionization = stats::setNames(c(1.007825),c("H")), +#' oligomerization_degree = 4) get_oligopeptides <- function(aminoacids, chemical_reaction, ionization, @@ -26,7 +30,8 @@ get_oligopeptides <- function(aminoacids, tmp_oligopeptides <- aminoacids all_mz_peptides <- build_mz_peptides(aminoacids, 1, ionization) for (i in 1:(oligomerization_degree-1)){ - tmp_oligopeptides <- oligopeptides_building(tmp_oligopeptides, aminoacids, chemical_reaction) + tmp_oligopeptides <- oligopeptides_building(tmp_oligopeptides, aminoacids, + chemical_reaction) tmp_mz_peptides <- build_mz_peptides(tmp_oligopeptides, i+1, ionization) all_mz_peptides <- rbind(all_mz_peptides, tmp_mz_peptides) } diff --git a/R/match_mz_obs.R b/R/match_mz_obs.R index fab10ac..82a2895 100644 --- a/R/match_mz_obs.R +++ b/R/match_mz_obs.R @@ -1,20 +1,22 @@ #' Match an observed mz against the combined compounds Robject using a δppm #' -#' @description Match an observed mz against the combined compounds Robject using a δppm +#' @description Match an observed mz against the combined +#' compounds Robject using a δppm #' @param mz_obs is the observed mz of the metabolomic study #' @param combined_compounds is the combined compounds array to match #' @param ppm_error is the criteria to match compounds -#' @return the list as dataframe of all the matches +#' @return the list as dataframe of all the matches +#' @importFrom dplyr %>% +#' @importFrom dplyr mutate +#' @importFrom dplyr filter #' @export -#' @examples - match_mz_obs <- function(mz_obs, combined_compounds, - ppm_error=5){ + ppm_error=5) { return(combined_compounds %>% - filter(combined_compounds% - filter(combined_compounds>=round(mz_obs, digits=0)) %>% - mutate(round = round(combined_compounds, digits=4)) %>% - mutate(ppm_error_value = d_ppm(round, mz_obs)) %>% - filter(ppm_error_value% + dplyr::filter(combined_compounds >= mz_obs - 1.0) %>% + dplyr::mutate(round = round(combined_compounds, digits=4)) %>% + dplyr::mutate(ppm_error_value = d_ppm(round, mz_obs)) %>% + dplyr::filter(ppm_error_value Date: Wed, 15 Mar 2023 15:42:33 +0100 Subject: [PATCH 02/19] add rshiny example --- .../app.R | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R diff --git a/exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R b/exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R new file mode 100644 index 0000000..03f9a5b --- /dev/null +++ b/exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R @@ -0,0 +1,99 @@ +library(shiny) +library(DT) + +# Constants +### Amino acids +aa <- c("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y") + +### amino acids molecular weight +mass_aa <- c(89.047679, 121.019751, 133.037509, 147.053159, 165.078979, + 75.032029, 155.069477, 131.094629, 146.105528, 131.094629, + 149.051051,132.053493, 115.063329, 146.069143, 174.111676, + 105.042594,119.058244, 117.078979,204.089878, 181.073894) + +aa_mw <- setNames(mass_aa, aa) + +### Polyphenols +polyphenol <- c("Cyanidin", + "Cyanidin 3,5-O-diglucoside", + "Cyanidin 3-O-(6''-acetyl-galactoside)", + "Cyanidin 3-O-(6''-acetyl-glucoside)", + "Cyanidin 3-O-(6''-caffeoyl-glucoside)") + +### polyphenol molecular weight +mass_polyphenol <- c(287.244, 611.525,491.422, 491.422, 611.527) + +pp_mw <- setNames(mass_polyphenol, polyphenol) + +### reaction elements +H2O <- 18.010565 +H <- 1.007825 + +ionization_list = stats::setNames(c(H),c("H")) + + +# See above for the definitions of ui and server +ui <- fluidPage( + + # App title ---- + titlePanel("Oligopeptides Matching"), + + # Sidebar layout with a input and output definitions ---- + sidebarLayout( + + # Sidebar panel for inputs ---- + sidebarPanel( + + # Input: Numeric entry for number of obs to view ---- + numericInput(inputId = "od", + label = "Oligomerization degree:", + value = 3), + numericInput(inputId = "mz_obs", + label = "M/z observed :", + value = 953.669), + numericInput(inputId = "ppm_error", + label = "Tolerance:", + value = 10) + ), + # Main panel for displaying outputs ---- + mainPanel( + h3("Oligopeptides"), + # Output: HTML table with requested number of observations ---- + DT::dataTableOutput("view") + ) + ) +) + +server <- function(input, output) { + + + + output$view <- DT::renderDataTable( + {aa_combined <- get_oligopeptides( + aminoacids = aa_mw, + chemical_reaction = H2O, + ionization = ionization_list, + oligomerization_degree = input$od) + + aa_combined_names <- c(aa_combined$id) + aa_combined_mass <- c(aa_combined$MW) + aa_combined_mw <- setNames(aa_combined_mass, aa_combined_names) + + combined_compounds <- get_combination_compounds( + compounds_1 = aa_combined_mw, + compounds_2 = pp_mw, + chemical_reaction = H2O, + ionization = setNames(c(H), c("H"))) + mz_obs <- 953.669 + combined_compounds_near_obs <- + match_mz_obs(input$mz_obs, combined_compounds, + ppm_error = input$ppm_error) + + return(combined_compounds_near_obs) + } + + ) + +} + +shinyApp(ui = ui, server = server) \ No newline at end of file From 65d7503a839e06056b6188f022d869dcc001afb3 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 14:48:46 +0100 Subject: [PATCH 03/19] fix import stringr --- NAMESPACE | 2 ++ R/oligopeptides_building.R | 2 ++ 2 files changed, 4 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index cb007cb..4e09340 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,3 +9,5 @@ export(oligopeptides_building) importFrom(dplyr,"%>%") importFrom(dplyr,filter) importFrom(dplyr,mutate) +importFrom(stringr,str_sort) +importFrom(stringr,str_split) diff --git a/R/oligopeptides_building.R b/R/oligopeptides_building.R index 5917662..5b20369 100644 --- a/R/oligopeptides_building.R +++ b/R/oligopeptides_building.R @@ -13,6 +13,8 @@ #' @param additional_reaction additional reaction linking the #' combination of oligopepid and amino acids. #' @return new oligo_vector with mass values . +#' @importFrom stringr str_split +#' @importFrom stringr str_sort #' @export #' @examples #' oligopeptides_building(stats::setNames(c(160,085358), From 3e0246003bcca87522a3c4bcdeacc3fde78fad8e Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 15:23:33 +0100 Subject: [PATCH 04/19] new docker image R --- .circleci/config.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 151d0e4..e570e4c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ workflows: jobs: build: docker: - - image: inraep2m2/ci-r-base-devtools:4.2.2 + - image: rocker/verse:4.2.3 steps: - checkout - run: @@ -21,12 +21,12 @@ jobs: command: R -e 'devtools::check()' # Probleme de generation du PDF avec le "R CMD check *tar.gz" # todo: ajouter la bonne lib dans inraep2m2/ci-r-base-devtools -# - run: -# name: Build package -# command: R CMD build . -# - run: -# name: Check package -# command: R CMD check *tar.gz + - run: + name: Build package + command: R CMD build . + - run: + name: Check package + command: R CMD check *tar.gz - store_artifacts: path: man/ destination: man \ No newline at end of file From 51d09cb6ea0c6403f8bd5099d1917ce6d8f9c0f0 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 15:57:56 +0100 Subject: [PATCH 05/19] up circleci --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e570e4c..ee4d49a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ workflows: jobs: build: docker: - - image: rocker/verse:4.2.3 + - image: inraep2m2/ci-r-base-devtools:4.2.2 steps: - checkout - run: @@ -23,10 +23,10 @@ jobs: # todo: ajouter la bonne lib dans inraep2m2/ci-r-base-devtools - run: name: Build package - command: R CMD build . + command: R CMD build --no-manual . - run: name: Check package - command: R CMD check *tar.gz + command: R CMD check --no-manual *tar.gz - store_artifacts: path: man/ - destination: man \ No newline at end of file + destination: man From 291256a4c9c2136964a31ed2612f357319247e6e Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 16:14:09 +0100 Subject: [PATCH 06/19] update README. update ci --- .circleci/config.yml | 19 ++++++++----------- README.md | 6 ++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ee4d49a..faf2129 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,15 +18,12 @@ jobs: command: R -e 'devtools::install_deps(dependencies = TRUE)' - run: name: Check package - command: R -e 'devtools::check()' -# Probleme de generation du PDF avec le "R CMD check *tar.gz" -# todo: ajouter la bonne lib dans inraep2m2/ci-r-base-devtools - - run: - name: Build package - command: R CMD build --no-manual . - - run: - name: Check package - command: R CMD check --no-manual *tar.gz + command: | + R -e 'devtools::check()' + export NAMEPACKAGE=$(grep Package DESCRIPTION | awk '{print $2}') + export VERSION=$(grep Version DESCRIPTION | awk '{print $2}') + R CMD build --no-manual . + R CMD check --no-manual ${NAMEPACKAGE}_${VERSION}.tar.gz - store_artifacts: - path: man/ - destination: man + path: . + destination: ${NAMEPACKAGE}_${VERSION}.tar.gz diff --git a/README.md b/README.md index 0c0832e..5427c23 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,13 @@ In order to compute from amino acids molecular weight the putative oligomers of ## Install Package locally +### from github repository +```R +devtools::install_github("p2m2/oligopeptides_matching") +``` + +### from source code ```R # if necessary... install.packages(devtools) From a7a3a57cb82594e1f955f1475e0089273125b407 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 16:27:27 +0100 Subject: [PATCH 07/19] test ci --- .circleci/config.yml | 55 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index faf2129..85ad908 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,10 +7,22 @@ workflows: - build: context: - DOCKER_CONTEXT + - publish-github-release: + requires: + - build + context: + - DOCKER_CONTEXT + - CREDENTIAL_CONTEXT + - GITHUB_CONTEXT + filters: + branches: + only: + - fix_import_stringr jobs: build: + working_directory: ~/tmp docker: - - image: inraep2m2/ci-r-base-devtools:4.2.2 + - image: inraep2m2/ci-r-base-devtools:4.2.3 steps: - checkout - run: @@ -20,10 +32,41 @@ jobs: name: Check package command: | R -e 'devtools::check()' - export NAMEPACKAGE=$(grep Package DESCRIPTION | awk '{print $2}') - export VERSION=$(grep Version DESCRIPTION | awk '{print $2}') + NAMEPACKAGE=$(grep Package DESCRIPTION | awk '{print $2}') + VERSION=$(grep Version DESCRIPTION | awk '{print $2}') R CMD build --no-manual . R CMD check --no-manual ${NAMEPACKAGE}_${VERSION}.tar.gz - - store_artifacts: - path: . - destination: ${NAMEPACKAGE}_${VERSION}.tar.gz + mkdir -p workspace + + - persist_to_workspace: + root: workspace + paths: + - ${NAMEPACKAGE}_${VERSION}.tar.gz + publish-github-release: + docker: + - image: circleci/golang:1.17 + steps: + - checkout + - attach_workspace: + at: workspace + - run: + name: "Publish Release on GitHub" + command: | + LAST_VERSION=$(git ls-remote --tags --sort="v:refname" https://${GITHUB_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git | tail -n1 | sed 's/.*\///; s/\^{}//') + NAMEPACKAGE=$(grep Package DESCRIPTION | awk '{print $2}') + VERSION=$(grep Version DESCRIPTION | awk '{print $2}') + # ------------------------------------------------------- + # utiliser gh ? => https://github.com/cli/cli/blob/trunk/docs/install_linux.md + # https://cli.github.com/manual/gh_release_create + # ------------------------------------------------------- + if [ "LAST_VERSION" != "VERSION" ]; then + go get github.com/tcnksm/ghr + BODY=$(changelog -a -f -) + ghr -t ${GITHUB_TOKEN} \ + -u ${CIRCLE_PROJECT_USERNAME} \ + -r ${CIRCLE_PROJECT_REPONAME} \ + -c ${CIRCLE_SHA1} \ + -n $VERSION \ + -b "$BODY" \ + -delete $VERSION ${NAMEPACKAGE}_${VERSION}.tar.gz + fi \ No newline at end of file From e827f71988effe7ace38ee1e7fc42a8fc267621c Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 16:33:06 +0100 Subject: [PATCH 08/19] fix ci --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 85ad908..612f535 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,6 +37,7 @@ jobs: R CMD build --no-manual . R CMD check --no-manual ${NAMEPACKAGE}_${VERSION}.tar.gz mkdir -p workspace + mv ${NAMEPACKAGE}_${VERSION}.tar.gz workspace/ - persist_to_workspace: root: workspace From 1cfd4eada20481a283ddf3d4a89a1151d521428e Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 16 Mar 2023 16:38:29 +0100 Subject: [PATCH 09/19] fix ci --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 612f535..fbbbf11 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,8 +42,10 @@ jobs: - persist_to_workspace: root: workspace paths: - - ${NAMEPACKAGE}_${VERSION}.tar.gz + - . + publish-github-release: + working_directory: ~/tmp docker: - image: circleci/golang:1.17 steps: @@ -69,5 +71,5 @@ jobs: -c ${CIRCLE_SHA1} \ -n $VERSION \ -b "$BODY" \ - -delete $VERSION ${NAMEPACKAGE}_${VERSION}.tar.gz + -delete $VERSION workspace/${NAMEPACKAGE}_${VERSION}.tar.gz fi \ No newline at end of file From acf790c396caed9aa3cc6cf1b232244786022017 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 11:27:33 +0100 Subject: [PATCH 10/19] fix changelog in ci to publish release --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index fbbbf11..f0362c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,6 +50,8 @@ jobs: - image: circleci/golang:1.17 steps: - checkout + - node/install: + node-version: '19.6' - attach_workspace: at: workspace - run: @@ -64,6 +66,8 @@ jobs: # ------------------------------------------------------- if [ "LAST_VERSION" != "VERSION" ]; then go get github.com/tcnksm/ghr + npm i generate-changelog -g + mv build/package.json . BODY=$(changelog -a -f -) ghr -t ${GITHUB_TOKEN} \ -u ${CIRCLE_PROJECT_USERNAME} \ From b66748fd02d5b88dfe40690333c74ba097cb77f0 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 11:39:07 +0100 Subject: [PATCH 11/19] fix changelog --- .circleci/config.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f0362c3..08dc594 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,9 +66,7 @@ jobs: # ------------------------------------------------------- if [ "LAST_VERSION" != "VERSION" ]; then go get github.com/tcnksm/ghr - npm i generate-changelog -g - mv build/package.json . - BODY=$(changelog -a -f -) + BODY="# ${NAMEPACKAGE} ${VERSION}" ghr -t ${GITHUB_TOKEN} \ -u ${CIRCLE_PROJECT_USERNAME} \ -r ${CIRCLE_PROJECT_REPONAME} \ From 84b13e5252d25d09df9f20b552f9e7efca4d1f16 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 11:39:28 +0100 Subject: [PATCH 12/19] fix changelog --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08dc594..a20f714 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -50,8 +50,6 @@ jobs: - image: circleci/golang:1.17 steps: - checkout - - node/install: - node-version: '19.6' - attach_workspace: at: workspace - run: From af808cc800c9474beec8b5dc272c0b36b744277d Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 13:32:18 +0100 Subject: [PATCH 13/19] add rshiny deployment in ci --- .circleci/config.yml | 28 ++++++++++++++-- .../app.R | 0 publish_rshinyapp.sh | 33 +++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) rename {exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement => oligopeptides_matching}/app.R (100%) create mode 100755 publish_rshinyapp.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index a20f714..256541a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,12 +12,25 @@ workflows: - build context: - DOCKER_CONTEXT - - CREDENTIAL_CONTEXT - GITHUB_CONTEXT filters: branches: only: + - main + - publish-shinyapp: + requires: + - build + context: + - DOCKER_CONTEXT + - SHINYAPP_CONTEXT + filters: + tags: + only: /.*/ + branches: + only: + - develop - fix_import_stringr + jobs: build: working_directory: ~/tmp @@ -72,4 +85,15 @@ jobs: -n $VERSION \ -b "$BODY" \ -delete $VERSION workspace/${NAMEPACKAGE}_${VERSION}.tar.gz - fi \ No newline at end of file + fi + + publish-shinyapp: + docker: + - image: inraep2m2/ci-r-base-devtools:4.2.3 + steps: + - checkout + - run: + name: deployment on https://www.shinyapps.io/ + command: | + [ -z "${CIRCLE_TAG}" ] && APP_NAME=${CIRCLE_BRANCH} || APP_NAME="oligopeptides_matching" + ./publish_rshinyapp.sh diff --git a/exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R b/oligopeptides_matching/app.R similarity index 100% rename from exampleOligopeptidesMatching_MzAgainstPolyphenolsArrangement/app.R rename to oligopeptides_matching/app.R diff --git a/publish_rshinyapp.sh b/publish_rshinyapp.sh new file mode 100755 index 0000000..516416c --- /dev/null +++ b/publish_rshinyapp.sh @@ -0,0 +1,33 @@ +#!/usr/bin/Rscript + +install.packages('rsconnect') + +library(devtools) +library(roxygen2) +document() +install() + +library(rsconnect) + +if ( nchar(Sys.getenv("SHINYAPPSIO_TOKEN"))<=0 ) { + write("** SHINYAPPSIO_TOKEN empty **",stderr()) + stop(1) +} + +if ( nchar(Sys.getenv("SHINYAPPSIO_SECRET"))<=0 ) { + write("** SHINYAPPSIO_SECRET empty **",stderr()) + stop(1) +} + +rsconnect::setAccountInfo(name='p2m2', + token=Sys.getenv("SHINYAPPSIO_TOKEN"), + secret=Sys.getenv("SHINYAPPSIO_SECRET")) + + +APP_NAME = Sys.getenv("APP_NAME") + +if ( nchar(APP_NAME)<=0 ) { + APP_NAME='oligopeptides_matching' +} + +rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE) \ No newline at end of file From cbe1c2c74eaf79f1c7f0478c69d2369c0b0386a7 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 13:37:13 +0100 Subject: [PATCH 14/19] add install dependancies --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 256541a..f714464 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,6 +92,9 @@ jobs: - image: inraep2m2/ci-r-base-devtools:4.2.3 steps: - checkout + - run: + name: Install package dependencies + command: R -e 'devtools::install_deps(dependencies = TRUE)' - run: name: deployment on https://www.shinyapps.io/ command: | From 7d638f2f9cdc127c7f06db5bfae37f897390a932 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 13:46:09 +0100 Subject: [PATCH 15/19] add shiny deps --- publish_rshinyapp.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/publish_rshinyapp.sh b/publish_rshinyapp.sh index 516416c..aae9a7c 100755 --- a/publish_rshinyapp.sh +++ b/publish_rshinyapp.sh @@ -30,4 +30,9 @@ if ( nchar(APP_NAME)<=0 ) { APP_NAME='oligopeptides_matching' } +install.packages("shiny") +install.packages("DT") +library(shiny) +library(DT) + rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE) \ No newline at end of file From c6312ab11fa2bca877b2d908844df4ac46fd5e5c Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 14:24:09 +0100 Subject: [PATCH 16/19] test deploy --- .circleci/config.yml | 3 ++- README.md | 1 + publish_rshinyapp.sh | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f714464..807b362 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,5 +98,6 @@ jobs: - run: name: deployment on https://www.shinyapps.io/ command: | - [ -z "${CIRCLE_TAG}" ] && APP_NAME=${CIRCLE_BRANCH} || APP_NAME="oligopeptides_matching" + [ -z "${CIRCLE_TAG}" ] && export APP_NAME="${CIRCLE_PROJECT_REPONAME}-${CIRCLE_BRANCH}" || export APP_NAME="${CIRCLE_PROJECT_REPONAME}" + echo "APPNAME=$APP_NAME" ./publish_rshinyapp.sh diff --git a/README.md b/README.md index 5427c23..12e7eeb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # oligopeptides_matching [![p2m2](https://circleci.com/gh/p2m2/oligopeptides_matching.svg?style=shield)](https://app.circleci.com/pipelines/github/p2m2) +[![](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://p2m2.shinyapps.io/oligopeptides_matching/) In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree diff --git a/publish_rshinyapp.sh b/publish_rshinyapp.sh index aae9a7c..5bf70ed 100755 --- a/publish_rshinyapp.sh +++ b/publish_rshinyapp.sh @@ -10,12 +10,12 @@ install() library(rsconnect) if ( nchar(Sys.getenv("SHINYAPPSIO_TOKEN"))<=0 ) { - write("** SHINYAPPSIO_TOKEN empty **",stderr()) + write("** SHINYAPPSIO_TOKEN empty ** check at https://www.shinyapps.io/admin/#/tokens",stderr()) stop(1) } if ( nchar(Sys.getenv("SHINYAPPSIO_SECRET"))<=0 ) { - write("** SHINYAPPSIO_SECRET empty **",stderr()) + write("** SHINYAPPSIO_SECRET empty ** check at https://www.shinyapps.io/admin/#/tokens",stderr()) stop(1) } @@ -24,8 +24,8 @@ rsconnect::setAccountInfo(name='p2m2', secret=Sys.getenv("SHINYAPPSIO_SECRET")) -APP_NAME = Sys.getenv("APP_NAME") - +APP_NAME <- Sys.getenv("APP_NAME") +write(APP_NAME) if ( nchar(APP_NAME)<=0 ) { APP_NAME='oligopeptides_matching' } From 824ddf8590db4649590dfd560dcbd33c21977da1 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 14:41:10 +0100 Subject: [PATCH 17/19] add rshiny publish --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 807b362..8771730 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,8 +29,6 @@ workflows: branches: only: - develop - - fix_import_stringr - jobs: build: working_directory: ~/tmp @@ -99,5 +97,4 @@ jobs: name: deployment on https://www.shinyapps.io/ command: | [ -z "${CIRCLE_TAG}" ] && export APP_NAME="${CIRCLE_PROJECT_REPONAME}-${CIRCLE_BRANCH}" || export APP_NAME="${CIRCLE_PROJECT_REPONAME}" - echo "APPNAME=$APP_NAME" ./publish_rshinyapp.sh From c4024d5df508648e4db67f7839ac3f108c92b684 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 14:43:04 +0100 Subject: [PATCH 18/19] update description --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ce1e1c6..595ee12 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: oligopeptidesMatching +Package: oligopeptides_matching Title: Library of functions for in silico construction and detection of oligopeptides Description: In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree. Version: 0.0.1 From 9cafbec32e51fec2e3c37d0a1e98f8e86e0f66d5 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 17 Mar 2023 14:55:40 +0100 Subject: [PATCH 19/19] update description --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 595ee12..ce1e1c6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: oligopeptides_matching +Package: oligopeptidesMatching Title: Library of functions for in silico construction and detection of oligopeptides Description: In order to compute from amino acids molecular weight the putative oligomers of various oligomerization degree. Version: 0.0.1