pubchemPIP <- function(db_path){
shinyApp(
ui = navbarPage("pubchemPIP",
tabPanel("Putative Ionisation Product",
# Create a new Row in the UI for selectInputs
fluidRow(
column(3, numericInput("acc_mz","Accurate Mass:",88.016045)),
column(2, numericInput("ppm","PPM:",1)),
column(2, checkboxInput("mode_p", "Positive Mode",value=F)),
column(2, checkboxInput("mode_ne", "Neutral",value=T)),
column(2, checkboxInput("mode_n", "Negative Mode",value=F))
#column(4, selectInput('add_sel_i', 'Adducts:', adducts, multiple=TRUE, selectize=FALSE))
),
fluidRow(
dataTableOutput(outputId="pip_table")
)
),
tabPanel("Draw Smiles",
sidebarPanel(
textInput("smile","Smiles:","O[C@@H](CC([O-])=O)C([O-])=O")
),
mainPanel(
plotOutput(outputId = "structure"),width=5
)
)
),
server = function(input, output) {
# Filter data based on selections
output$pip_table <- renderDataTable({
if(input$mode_p){
mode <- "p"
}
if(input$mode_n){
mode <- "n"
}
if(input$mode_ne){
mode <- "ne"
}
pip_tab <- queryPubchem(input$acc_mz,input$ppm,mode,db_path)
pip_tab
})
output$structure <- renderPlot({
par(mar=c(0,0,0,0))
sm <- parse.smiles(input$smile)[[1]]
temp1 <- view.image.2d(sm,500,500)
plot(NA,NA,xlim=c(1,100),ylim=c(1,100),xaxt='n',yaxt='n',xlab='',ylab='')
rasterImage(temp1,1,1,100,100) # boundaries of raster: xmin, ymin, xmax, ymax. here i set them equal to plot boundaries
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.