Skip to content

Commit

Permalink
Merge pull request #8 from EMSL-Computing/feature/minio-connection
Browse files Browse the repository at this point in the history
Feature/minio connection
  • Loading branch information
clabornd authored Feb 8, 2024
2 parents 6d631f5 + 9da1918 commit 38c9556
Show file tree
Hide file tree
Showing 58 changed files with 5,912 additions and 3,198 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
!calculation_options.csv
!calculation_variables.csv
!processedCols.csv
!isotopes.json
!DataRequirements.md
!Docker_instructions.md
!peakData_Report.Rmd
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,9 @@ tests/test_*/
script_dump.R
packrat/lib*/
Data/
untracked_resources
cfg
!cfg/minio_config_example.yml
!cfg/minio_config_corems.yml
renv
!renv/settings.json
3 changes: 3 additions & 0 deletions .renvignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
untracked_resources
.git
tests/
51 changes: 51 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Package: FREDA
Title: An app for the processing and visualization of Fourier-transform mass spectrometry data.
Version: 1.7
Authors@R: c(person("Lisa", "Bramer", "[email protected]", role = "aut", "cre"),
person("Daniel", "Claborne", "[email protected]", role = c("aut")))
Description: A frontend application which exposes functionality of the ftmsRanalysis R package. See
License: GPL (>= 3) + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
Depends:
R (>= 4.1.0)
Imports:
dplyr,
DT,
ggplot2,
htmlwidgets,
jsonlite,
kableExtra,
KeggData,
knitr,
markdown,
pander,
plotly,
purrr,
raster,
RColorBrewer,
readr,
reshape2,
reticulate,
rlang,
rmarkdown,
scales,
shiny,
shinyBS,
shinycssloaders,
shinyjs,
shinyWidgets,
sp,
stringr,
tibble,
tidyr,
viridis,
webshot,
withr,
xfun,
MetaCycData,
mapDataAccess,
ftmsRanalysis,
datadr

11 changes: 0 additions & 11 deletions Docker_instructions.md

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY . /srv/shiny-server/FREDA
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

# App is run as user shiny, need to change ownership
RUN chown -R shiny:shiny /srv/shiny-server/FREDA /opt/orca/squashfs-root
RUN chown -R shiny:shiny /srv/shiny-server/FREDA
37 changes: 8 additions & 29 deletions Dockerfile-base
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
FROM rocker/shiny:4.1.1
FROM rocker/shiny:4.2.3

RUN apt-get update -qq && apt-get install -y \
git-core \
libssl-dev \
libcurl4-gnutls-dev \
libmagick++-dev \
libv8-dev \
vim python3-venv
vim python3-venv \
libgdal-dev

WORKDIR /srv/shiny-server/
COPY renv.lock .

# pre-install renv
RUN R -e "install.packages('renv', repos = 'https://cran.rstudio.com')"
ENV RENV_VERSION 1.0.3
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "options('repos'=c(CRAN = 'https://cloud.r-project.org'));remotes::install_version('renv', version = '${RENV_VERSION}')"

# install all packages listed in renv.lock
COPY renv.lock .
RUN --mount=type=secret,id=access_tokens set -a \
&& . /run/secrets/access_tokens && set +a \
&& R -e 'renv::restore()'
&& R -e 'options(renv.config.connect.timeout=300);options(timeout=300);renv::restore()'

## Setup Python venv ##
USER root
COPY python_requirements.txt .
RUN python3 -m venv /venv
RUN /venv/bin/pip install --upgrade pip
RUN /venv/bin/pip install -r python_requirements.txt

# Install all plotly's dependencies
RUN R -e "install.packages('plotly', dependencies = T)"

# Download orca binary and make it executable under xvfb
RUN apt-get update && \
apt-get install -y --no-install-recommends \
xvfb \
xauth \
libgtk2.0-0 \
libxtst6 \
libxss1 \
libgconf-2-4 \
libnss3 \
libasound2 && \
mkdir -p /opt/orca && \
cd /opt/orca && \
wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage && \
chmod +x orca-1.2.1-x86_64.AppImage && \
./orca-1.2.1-x86_64.AppImage --appimage-extract && \
rm orca-1.2.1-x86_64.AppImage && \
printf '#!/bin/bash \nxvfb-run --auto-servernum --server-args "-screen 0 640x480x24" /opt/orca/squashfs-root/app/orca "$@"' > /usr/bin/orca && \
chmod +x /usr/bin/orca && \
apt-get remove -y libnode-dev

123 changes: 123 additions & 0 deletions Observers/corems_observers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#' @details Convert the filtered corems data to peakData
#' cms_dat_unq_mf() is converted into peakData using CoreMSData_to_ftmsData and
#' the result is stored in revals$uploaded_data
observeEvent(
c(
input$corems_to_peakdata,
input$corems_to_peakdata_modal
), {

req(cms_dat_unq_mf())
req(isTruthy(input$corems_to_peakdata > 0) | isTruthy(input$corems_to_peakdata_modal > 0))

revals$uploaded_data <- revals$peakData2 <- NULL

res <- tryCatch({
ftmsRanalysis::coreMSDataToFtmsData(cms_dat_unq_mf())
},
error = function(e) {
msg = paste0('Error converting your coreMS data to peakData: \n System error: ', e)
revals$warningmessage_corems$corems_to_peakdata <<- sprintf("<p style = 'color:red'>%s</p>", msg)
revals$warningmessage_corems$corems_to_peakdata
})

if (inherits(res, "peakData")) {
# need a fake f_data column.
if (ncol(res$f_data) == 1) {
res$f_data[, 2] <- NA
}

revals$uploaded_data <- res
} else {
if (inherits(res, "character")) {
msg = res
} else {
msg = "Error converting your coreMS data to peakData"
}

showNotification(
HTML(msg),
duration = NULL,
type = "error"
)
}
}, ignoreInit = T)

#' @details Show a modal for the completion of corems data
observeEvent(cms_data(), {
req(cms_data(), input$top_page == "CoreMS-create")

updateCollapse(session, id = "corems-upload-summary-collapse",
open = c("corems-upload-visualize"), close = c("corems-upload-table"))

showModal(
# defined in srv_ui_elements/corems_UI.R
corems_obj_creation_modal()
)
})

#' @details Go to the corems filter tab from the object creation success tab.
observeEvent(input$goto_corems_filter, {
req(input$top_page == "CoreMS-create")
updateTabsetPanel(inputId = "top_page", selected = "CoreMS-conf-filter")
removeModal()
})

#' @details Move the user to the create CoreMSData tab after successful upload
observeEvent(input$goto_corems_creation, {
updateTabsetPanel(inputId = "top_page", selected = "CoreMS-create")
removeModal()
})

#' @details (CoreMS filter tab) Show summary plot and show progression modal
observeEvent(cms_data_filtered(), {
req(cms_data_filtered())
updateCollapse(session, id = "corems-filter-summary-collapse",
open = c("viz"))
updateTabsetPanel(inputId = "corems-viz-tabset", selected = "filt_summary_plot")

showModal(corems_filter_modal())
})

#' @details Move user to the formula assignment tab after successful filtering
observeEvent(input$goto_corems_formula, {
updateTabsetPanel(inputId = "top_page", selected = "CoreMS-formula-assign")
removeModal()
})

#' @details display table visualization panels and prompt user for next steps
#' when unique molecular formula are assigned.
observeEvent(cms_dat_unq_mf(), {
hide("corems_to_peakdata_toggle")
req(cms_dat_unq_mf())
updateCollapse(session, id = "corems-assign-formula", open = c("viz", "tables"))
showModal(corems_unq_mf_modal())
show("corems_to_peakdata_toggle")
})

#' @details disable functionality and helper css for arguments required for corems
observe({
req(input$top_page == "CoreMS-create")
fields_filled = TRUE

for(arg in COREMSDATA_REQ_ARGS) {
is_selected = isTruthy(input[[arg]] != NULLSELECT__)
toggleCssClass(sprintf("%s_UI", arg), "attention", !is_selected)
if(!is_selected) {
fields_filled = FALSE
}
}

toggleState("make_cmsdata", condition = fields_filled)

if (!fields_filled) {
showNotification(
ui = "One or more required fields for making your coreMS data object are not specified",
type = "warning",
id = "as-corems-args-notification"
)
} else {
removeNotification("as-corems-args-notification")
}

})
Loading

0 comments on commit 38c9556

Please sign in to comment.