How to define an Input as a DNAString?

Hello :slight_smile:

I'm new to r and shiny and don't know a lot. But I want to ask if it is possible to define an Input as an DNAString.. For the Input you have to add a DNA Sequence in FASTA-Format like TCTAGAT
For the Output I want it in reverse and compliment --> ATCTAGA

therefore i can use
reverseCompliment(DNAString("TCTAGAT"))

or define x <- DNAString("TCTAGAT")
and use reverseCompliment(x)

but I can not use DNAString("input$...)

Here is my code... (input$bip should be reverse and complement)!!!


library(shiny)
library(shinythemes)

Definiere UI

ui <- fluidPage(theme = shinytheme("sandstone"),

            # Titel     
            navbarPage("",
                       
                       # Tab 1
                       tabPanel("",
                                
                                # Eingabefeld                  
                                sidebarPanel(width = 12,
                                             
                                             # Textfeld zum Einfügen des Gens                                
                                             tags$h4("Gensequenz:"),
                                             
                                             textInput("gen", "FASTA-Format", "", placeholder = "Sequenz hier einfügen..."),
                                             
                                             # Textfeld zum Einfügen des FIP-Primers
                                             tags$h4("Primersequenzen:"),
                                             
                                             textInput("fip", "FIP-Primer", "", placeholder = "Primersequenz einfügen"),
                                             
                                             # Textfeld zum Einfügen des BIP-Primers
                                             textInput("bip", "BIP-Primer", "", placeholder = "Primersequenz einfügen"),
                                             
                                             
                                ), # sidebarPanel
                                
                                # Ausgabefelder              
                                mainPanel(
                                  
                                  h3("Position der Primer"),
                                  
                                  h5("FIP-Primer"),
                                  verbatimTextOutput("fippos"),
                                  
                                  h5("BIP-Primer"),
                                  verbatimTextOutput("bippos"),
                                  
                                  h3("Länge der Zielsequenz"),
                                  
                                  h5("Anzahl Basen"),
                                  verbatimTextOutput("s"),
                                  
                                  h3("GC-Gehalt"),
                                  
                                  h5("Anzahl GC"),
                                  verbatimTextOutput("gc"),
                                  
                                  h5("GC-Gehalt in %"),
                                  verbatimTextOutput("prozent"),
                                  
                                ), # mainPanel
                                
                       ), # tabPanel 1
                  
            ) # navbarPage

) # fluidPage

Server Funktion

server <- function(input, output) {

output$fippos <- renderText({
(str_locate ( input$gen , input$fip ))
})

output$bippos <- renderText({

(str_locate ( input$gen , input$bip))

})

output$s <- renderText({
(nchar( input$gen ))
})

output$gc <- renderText({
((lengths(regmatches(input$gen, gregexpr("G", input$gen, ignore.case = TRUE))))
+(lengths(regmatches(input$gen, gregexpr("C", input$gen, ignore.case = TRUE)))))
})

output$prozent <- renderText({
round(
((((lengths(regmatches(input$gen, gregexpr("G", input$gen, ignore.case = TRUE))))
+(lengths(regmatches(input$gen, gregexpr("C", input$gen, ignore.case = TRUE)))))
/(nchar( input$gen )))*100)
,2)
})

} # server

Shiny-App erstellen

shinyApp(ui = ui, server = server)


Thank you alot :slight_smile:

TCTAGAT is quoted "" so it's interpreted as a string and not some variable called TCTAGAT which contains a string to be looked at. Whereas input$whatever is a variable that should be evaluated to get a string out of, so should not be quoted ""

1 Like

Thank you for the fast respond!

And how can I evaluate the input$... to become a string?