Afegit acció del butó, així com opció d'output fasta o taula.
This commit is contained in:
@@ -15,13 +15,15 @@ ui <- fluidPage(
|
||||
selectInput("spec", label = h3("Specie"),
|
||||
choices = list("Human" = 1, "E. Coli" = 2),
|
||||
selected = 1),
|
||||
actionButton("calab", "Analizar")
|
||||
actionButton("but_an", "Analizar"),
|
||||
selectInput("for_output", label = h3("Formato Output"),
|
||||
choices = list("fasta" = 1, "tabla" = 2),
|
||||
selected = 1),
|
||||
),
|
||||
|
||||
mainPanel(
|
||||
textAreaInput("seqText", label="Enter mFasta text", width = "100%", height = "500px", value=""),
|
||||
# tags$head(tags$style(HTML("pre { white-space: pre-wrap; word-break: break-all; }"))),
|
||||
htmlOutput("seqDNA")
|
||||
uiOutput("seqDNAui")
|
||||
)
|
||||
),
|
||||
tabPanel("Codon Frequency Table",
|
||||
@@ -34,12 +36,24 @@ ui <- fluidPage(
|
||||
|
||||
# Define server
|
||||
server <- function(input, output) {
|
||||
obj<-reactiveValues()
|
||||
obj$fasta<-NULL
|
||||
obj$seqs<-NULL
|
||||
obj$names<-NULL
|
||||
|
||||
output$seqDNA <- renderText({
|
||||
observe({
|
||||
if (!is.null(input$file1)){ # This ensures that the reading is only tried when File selected
|
||||
obj$fasta<-read.fasta(input$file1$datapath)
|
||||
}
|
||||
})
|
||||
|
||||
revtrans<-eventReactive(input$but_an, {
|
||||
if (input$seqText != "" | !is.null(obj$fasta)){
|
||||
if (input$seqText == ""){
|
||||
print("Result")
|
||||
seqs<-obj$fasta
|
||||
}else{
|
||||
seqs<-strsplit(input$seqText,"\n")[[1]]
|
||||
}
|
||||
names_seqs<-seqs[grepl("^>",seqs)]
|
||||
names_seqs<-gsub(">","", names_seqs)
|
||||
seqs<-seqs[!grepl("^>", seqs)]
|
||||
@@ -54,18 +68,44 @@ server <- function(input, output) {
|
||||
seqs_DNA<-c(seqsDNA<-reverse_translate(seqs[i],spec))
|
||||
progress$set(message = "Reverse Translating", value = i)
|
||||
}
|
||||
|
||||
paste(dataframe2fas(data.frame(names=names_seqs,
|
||||
seqs=seqs_DNA)), collapse="<br>")
|
||||
progress$close()
|
||||
obj$seqs<-seqs_DNA
|
||||
obj$names<-names_seqs
|
||||
}
|
||||
})
|
||||
|
||||
output$seqDNA <- renderText({
|
||||
print(1)
|
||||
observeEvent(input$but_an, {revtrans()})
|
||||
if (!is.null(obj$seqs)){
|
||||
paste(dataframe2fas(data.frame(names=obj$names, seqs=obj$seqs)), collapse="<br>")
|
||||
}
|
||||
})
|
||||
|
||||
output$seqDNAt <- renderTable({
|
||||
print(2)
|
||||
observeEvent(input$but_an, {revtrans()})
|
||||
if (!is.null(obj$seqs)){
|
||||
data.frame("Nombre"=obj$names, "Seqs"=obj$seqs)
|
||||
}
|
||||
})
|
||||
|
||||
{
|
||||
output$tbl <- renderTable({
|
||||
if(input$spec == 1){spec<-hsapien_tbl}
|
||||
if(input$spec == 2){spec<-ecoli_tbl}
|
||||
spec %>% arrange(aa)
|
||||
spec[order(spec$aa),]
|
||||
})
|
||||
}
|
||||
|
||||
output$seqDNAui<-renderUI({
|
||||
observeEvent(input$but_an, {})
|
||||
if (input$for_output == 1){
|
||||
htmlOutput("seqDNA")
|
||||
}else{
|
||||
tableOutput("seqDNAt")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
# Run the application
|
||||
|
||||
Reference in New Issue
Block a user