diff --git a/.circleci/config.yml b/.circleci/config.yml index 8771730..8c5748d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,13 +22,12 @@ workflows: - build context: - DOCKER_CONTEXT + - GITHUB_CONTEXT - SHINYAPP_CONTEXT filters: tags: only: /.*/ - branches: - only: - - develop + jobs: build: working_directory: ~/tmp @@ -96,5 +95,7 @@ jobs: - run: 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}" + # publish only tag release + export APP_NAME="${CIRCLE_PROJECT_REPONAME}" + export GITHUB_PAT=${GITHUB_TOKEN} ./publish_rshinyapp.sh diff --git a/DESCRIPTION b/DESCRIPTION index ce1e1c6..72e61b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ 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 +Version: 0.0.2 Authors@R: c( person(given = "Kevin", family = "Billet", diff --git a/README.md b/README.md index 12e7eeb..2cda07b 100644 --- a/README.md +++ b/README.md @@ -1,7 +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/) +[![](https://img.shields.io/badge/stable-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 @@ -109,12 +109,11 @@ install.packages("shiny") install.packages("DT") library(shiny) -library(DT) library(devtools) library(roxygen2) document() -runApp("exampleOligopeptidesMatching_aa") +runApp("oligopeptides_matching") ``` ### Examples diff --git a/oligopeptides_matching/app.R b/oligopeptides_matching/app.R index 03f9a5b..c28aa4e 100644 --- a/oligopeptides_matching/app.R +++ b/oligopeptides_matching/app.R @@ -1,99 +1,6 @@ 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) - } - - ) - -} +source(server.R) +source(ui.R) shinyApp(ui = ui, server = server) \ No newline at end of file diff --git a/oligopeptides_matching/data.R b/oligopeptides_matching/data.R new file mode 100644 index 0000000..9150158 --- /dev/null +++ b/oligopeptides_matching/data.R @@ -0,0 +1,29 @@ +# 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")) \ No newline at end of file diff --git a/oligopeptides_matching/server.R b/oligopeptides_matching/server.R new file mode 100644 index 0000000..b644797 --- /dev/null +++ b/oligopeptides_matching/server.R @@ -0,0 +1,42 @@ +library(shiny) +library(DT) +library(oligopeptidesMatching) + +source("./data.R") + +server <- function(input, output) { + + combination_compounds <- reactive({ + aaa_combined <- get_oligopeptides( + aminoacids = aa_mw, + chemical_reaction = H2O, + ionization = ionization_list, + oligomerization_degree = input$od) + + aa_combined <- as.data.frame(aaa_combined) + aa_combined_names <- c(aa_combined$id) + aa_combined_mass <- c(aa_combined$MW) + aa_combined_mw <- setNames(aa_combined_mass, aa_combined_names) + + return(get_combination_compounds(compounds_1 = aa_combined_mw, + compounds_2 = pp_mw, + chemical_reaction = H2O, + ionization = setNames(c(H),c("H")))) + }) + # ===== + # All arrangement AA with PolyPhenols + output$view_arrangement <- DT::renderDataTable( + combination_compounds() + ) + # ===== + # Filtering on a single Value + + output$view_filter_mz_obs <- DT::renderDataTable( + { + return(match_mz_obs( + input$mz_obs, + combination_compounds(), + ppm_error = input$ppm_error)) + } + ) +} \ No newline at end of file diff --git a/oligopeptides_matching/ui.R b/oligopeptides_matching/ui.R new file mode 100644 index 0000000..32f5d90 --- /dev/null +++ b/oligopeptides_matching/ui.R @@ -0,0 +1,44 @@ +ui <- navbarPage("Oligopeptides Matching", + tabPanel("Combination AA Polyphenol", + + # 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) + ), + # Main panel for displaying outputs ---- + mainPanel( + h3("Oligopeptides"), + # Output: HTML table with requested number of observations ---- + DT::dataTableOutput("view_arrangement") + ) + ) +), +tabPanel("Match a single Mz", +# Sidebar layout with a input and output definitions ---- + sidebarLayout( + + # Sidebar panel for inputs ---- + sidebarPanel( + 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_filter_mz_obs") + ) + ) +), +tabPanel("Match a list of Mz") +) \ No newline at end of file diff --git a/publish_rshinyapp.sh b/publish_rshinyapp.sh index 5bf70ed..a98dd34 100755 --- a/publish_rshinyapp.sh +++ b/publish_rshinyapp.sh @@ -2,10 +2,10 @@ install.packages('rsconnect') -library(devtools) -library(roxygen2) -document() -install() +#library(devtools) +#library(roxygen2) +#document() +#install() library(rsconnect) @@ -32,7 +32,6 @@ if ( nchar(APP_NAME)<=0 ) { install.packages("shiny") install.packages("DT") -library(shiny) -library(DT) +devtools::install_github("p2m2/oligopeptides_matching") -rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE) \ No newline at end of file +rsconnect::deployApp('oligopeptides_matching',appName=APP_NAME,forceUpdate = TRUE)