Skip to content

Commit

Permalink
Merge pull request #1020 from Layth17/master
Browse files Browse the repository at this point in the history
Docker image to run pvacview on GCP
  • Loading branch information
susannasiebert authored Feb 13, 2024
2 parents 562e815 + 588ffe1 commit e85394e
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 12 deletions.
8 changes: 4 additions & 4 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ Download the archives for `class I <http://tools.iedb.org/mhci/download/>`_ and
.. code-block:: none
apt-get update && apt-get install -y tcsh gawk
wget https://downloads.iedb.org/tools/mhci/3.1.2/IEDB_MHC_I-3.1.2.tar.gz
tar -zxvf IEDB_MHC_I-3.1.2.tar.gz
wget https://downloads.iedb.org/tools/mhci/3.1.5/IEDB_MHC_I-3.1.5.tar.gz
tar -zxvf IEDB_MHC_I-3.1.5.tar.gz
cd mhc_i
./configure
Expand All @@ -90,8 +90,8 @@ Download the archives for `class II <http://tools.iedb.org/mhcii/download/>`_ an
.. code-block:: none
apt-get update && apt-get install -y tcsh gawk
wget https://downloads.iedb.org/tools/mhcii/3.1.6/IEDB_MHC_II-3.1.6.tar.gz
tar -zxvf IEDB_MHC_II-3.1.6.tar.gz
wget https://downloads.iedb.org/tools/mhcii/3.1.11/IEDB_MHC_II-3.1.11.tar.gz
tar -zxvf IEDB_MHC_II-3.1.11.tar.gz
cd mhc_ii
./configure.py
Expand Down
31 changes: 31 additions & 0 deletions pvactools/tools/pvacview/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
FROM rocker/shiny-verse

RUN R -e "install.packages(c('shiny',\
'shinyjs',\
'shinythemes',\
'plotly', \
'RMySQL',\
'ggplot2',\
'DT',\
'reshape2',\
'jsonlite',\
'tibble',\
'tidyr',\
'plyr',\
'dplyr',\
'stringr', \
'shinydashboard', \
'shinydashboardPlus', \
'shinycssloaders', \
'fresh', \
'RCurl' ), repos='https://cran.rstudio.com/')"

RUN R -e "devtools::install_github('eclarke/ggbeeswarm', ref='v0.6.1')"

RUN rm -rf /srv/shiny-server/*

COPY . /srv/shiny-server/

EXPOSE 3333

CMD ["R", "-e", "shiny::runApp('/srv/shiny-server/', port = 3333, host='0.0.0.0')"]
2 changes: 1 addition & 1 deletion pvactools/tools/pvacview/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library(shiny)
source(server.R)
source(ui.R)

options(shiny.host = '127.0.0.1')
options(shiny.host = '0.0.0.0')
options(shiny.port = 3333)

shinyApp(ui, server)
137 changes: 137 additions & 0 deletions pvactools/tools/pvacview/gcloud_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
IMAGE_NAME="pvacview"
TAG_NAME="latest" # do not change this unless you have looked at how your service fetches the tag
REGION="us-central1"
LAB="griffith-lab" # also the project name
REPO="shiny-apps"
SERVICE_NAME="pvacview"
SERVICE_TAG=$2 # format like: v1-0-0

# script
COMMAND=$1 # init or update

function show_help {
echo "usage: sh gcloud_service.sh COMMAND <TAG>"
echo ""
echo "commands:"
echo " init Creates a new service in Cloud Run."
echo " update updates an existing service in Cloud Run."
echo ""
echo "arguments:"
echo " <TAG> Positional argument that tags the revision/release of the service (example: v1-0-0)."
echo ""
}

function validate {
# check if Docker is running
if ! docker info >/dev/null 2>&1; then
echo "ERROR: Docker does not appear to be running. Please start Docker."
# Exit with a non-zero status to indicate that Docker isn't running
exit 1
fi

# check if you are logged in
if [[ -z $(gcloud auth list --filter=status:ACTIVE --format="value(account)") ]]; then
echo "<< Please log in.>>"
gcloud auth login
else
echo "<< [Alread logged in]: Welcome, $(gcloud auth list --filter=status:ACTIVE --format="value(account)") >>"
fi

# check if user is allowed to push to Artifact Registry
if [[ -z $(cat ~/.docker/config.json | grep "\"$REGION-docker.pkg.dev\": \"gcloud\"") ]]; then
echo "<< Attempting to Authenticate before pushing to Artifact Registry. >>"
gcloud auth configure-docker $REGION-docker.pkg.dev
else
echo "<< Allowed to push to Artifact Registry >>"
fi
}

function build_and_push_image {
# build the image
docker build . --tag $REGION-docker.pkg.dev/$LAB/$REPO/$IMAGE_NAME:$TAG_NAME

# Check the exit code of the docker build command
if [ $? -ne 0 ]; then
echo "Error: Docker build failed"
exit 1
fi

# push the image
docker push $REGION-docker.pkg.dev/$LAB/$REPO/$IMAGE_NAME:$TAG_NAME

# Check the exit code of the docker push command
if [ $? -ne 0 ]; then
echo "Error: Docker push failed"
exit 1
fi
}

function init {
build_and_push_image

# deploy: https://cloud.google.com/sdk/gcloud/reference/run/deploy
gcloud --project $LAB run deploy $SERVICE_NAME \
--image $REGION-docker.pkg.dev/$LAB/$REPO/$IMAGE_NAME:$TAG_NAME \
--port=3333 \
--min-instances=0 \
--max-instances=100 \
--memory=2Gi \
--cpu=4 \
--timeout=300 \
--allow-unauthenticated \
--update-env-vars KEY=VALUE --revision-suffix $SERVICE_TAG
}

function update {
# check SERVICE_TAG does not already exist
TAGS=$(gcloud run revisions list --project $LAB --service $SERVICE_NAME --format="value(REVISION)")
if [[ $TAGS =~ $SERVICE_TAG ]]; then
echo "ERROR: The Service \"$SERVICE_NAME\" already has revision $SERVICE_TAG. Please use a new tag."
exit 1
fi

# set region; updating service will ask for region if this is not set
if [[ $(gcloud config get-value run/region) != "$REGION" ]]; then
echo "<< Upadting property [run/region] to $REGION >>"
gcloud config set run/region $REGION
fi

build_and_push_image

# update service
if [[ -z $(gcloud --project $LAB run services list | grep -w $SERVICE_NAME) ]]; then
echo "<<ERROR: Your service does not exist. You must initialize it first. >>"
else
gcloud --project $LAB run services update $SERVICE_NAME --update-env-vars KEY=VALUE --revision-suffix $SERVICE_TAG
fi
}

if [[ ($COMMAND != "init") && ($COMMAND != "update")]]; then
show_help
echo "ERROR: invalid command."
exit 1
else
validate
case $COMMAND in
"init")
init
;;
"update")
update
;;
esac
fi














14 changes: 7 additions & 7 deletions pvactools/tools/pvacview/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ source("styling.R")

#specify max shiny app upload size (currently 300MB)
options(shiny.maxRequestSize = 300 * 1024^2)
options(shiny.host = '127.0.0.1')
options(shiny.host = '0.0.0.0')
options(shiny.port = 3333)

server <- shinyServer(function(input, output, session) {
Expand Down Expand Up @@ -73,7 +73,7 @@ server <- shinyServer(function(input, output, session) {
colnames(mainData) <- mainData[1, ]
mainData <- mainData[-1, ]
row.names(mainData) <- NULL
mainData$`Eval` <- shinyInput(mainData, selectInput, nrow(mainData), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
mainData$`Eval` <- shinyInput(mainData, selectInput, nrow(mainData), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
mainData$Select <- shinyInputSelect(actionButton, nrow(mainData), "button_", label = "Investigate", onclick = 'Shiny.onInputChange(\"select_button\", this.id)')
mainData$`IC50 MT` <- as.numeric(mainData$`IC50 MT`)
mainData$`%ile MT` <- as.numeric(mainData$`%ile MT`)
Expand Down Expand Up @@ -157,7 +157,7 @@ server <- shinyServer(function(input, output, session) {
colnames(mainData) <- mainData[1, ]
mainData <- mainData[-1, ]
row.names(mainData) <- NULL
mainData$`Eval` <- shinyInput(mainData, selectInput, nrow(mainData), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
mainData$`Eval` <- shinyInput(mainData, selectInput, nrow(mainData), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
mainData$Select <- shinyInputSelect(actionButton, nrow(mainData), "button_", label = "Investigate", onclick = 'Shiny.onInputChange(\"select_button\", this.id)')
mainData$`IC50 MT` <- as.numeric(mainData$`IC50 MT`)
mainData$`%ile MT` <- as.numeric(mainData$`%ile MT`)
Expand Down Expand Up @@ -332,7 +332,7 @@ server <- shinyServer(function(input, output, session) {
df$mainTable$`Rank_ic50` <- NULL
df$mainTable$`Rank_expr` <- NULL
df$mainTable$Select <- shinyInputSelect(actionButton, nrow(df$mainTable), "button_", label = "Investigate", onclick = 'Shiny.onInputChange(\"select_button\", this.id)')
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
})
#reset tier-ing with original parameters
observeEvent(input$reset_params, {
Expand Down Expand Up @@ -368,7 +368,7 @@ server <- shinyServer(function(input, output, session) {
df$mainTable$`Rank_ic50` <- NULL
df$mainTable$`Rank_expr` <- NULL
df$mainTable$Select <- shinyInputSelect(actionButton, nrow(df$mainTable), "button_", label = "Investigate", onclick = 'Shiny.onInputChange(\"select_button\", this.id)')
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
})
#determine hla allele count in order to generate column tooltip locations correctly
hla_count <- reactive({
Expand Down Expand Up @@ -432,7 +432,7 @@ server <- shinyServer(function(input, output, session) {
df$pageLength <- as.numeric(input$page_length)
session$sendCustomMessage("unbind-DT", "mainTable")
df$mainTable$`Evaluation` <- shinyValue("selecter_", nrow(df$mainTable), df$mainTable)
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
})
output$filesUploaded <- reactive({
val <- !(is.null(df$mainTable) | is.null(df$metricsData))
Expand Down Expand Up @@ -541,7 +541,7 @@ server <- shinyServer(function(input, output, session) {
df$selectedRow <- as.numeric(strsplit(input$select_button, "_")[[1]][2])
session$sendCustomMessage("unbind-DT", "mainTable")
df$mainTable$`Evaluation` <- shinyValue("selecter_", nrow(df$mainTable), df$mainTable)
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "60px")
df$mainTable$`Eval` <- shinyInput(df$mainTable, selectInput, nrow(df$mainTable), "selecter_", choices = c("Pending", "Accept", "Reject", "Review"), width = "90px")
dataTableProxy("mainTable") %>%
selectPage((df$selectedRow - 1) %/% df$pageLength + 1)
})
Expand Down

0 comments on commit e85394e

Please sign in to comment.