forked from sawsimeon/HDP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Server.R
108 lines (85 loc) · 2.48 KB
/
Server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
library(shiny)
library(seqinr)
library(protr)
library(caret)
library(randomForest)
library(shinyjs)
library(dplyr)
library(conformal)
library(RWeka)
combine_data <- readRDS("data.Rds")
fit <- J48(Label~., data = combine_data)
shinyServer(function(input, output, session) {
observe({
FASTADATA <- ''
fastaexample <- '>HDP-Bacteria
KVLKAAAKAALNAVLVGANA
'
if(input$addlink>0) {
isolate({
FASTADATA <- fastaexample
updateTextInput(session, inputId = "Sequence", value = FASTADATA)
})
}
})
observe({
emptyDATA <- ""
if(input$clearbutton>0) {
isolate({
updateTextInput(session, inputId = "Sequence", value = emptyDATA)
is.null(datasetInput())
})
}
})
datasetInput <- reactive({
inFile <- input$file1
inTextbox <- input$Sequence
if (is.null(inTextbox)) {
return("Please insert/upload sequence in FASTA format")
} else {
if (is.null(inFile)) {
x <- inTextbox
write.fasta(sequence = x, names = names(x),
nbchar = 80, , file.out = "text.fasta")
x <- readFASTA("text.fasta")
x <- x[(sapply(x, protcheck))]
ACC <- t(sapply(x, extractAAC))
test <- data.frame(ACC)
Prediction <- predict(fit, test)
Prediction <- as.data.frame(Prediction)
Protein <- cbind(Name = rownames(test, test))
results <- cbind(Protein, Prediction)
results <- data.frame(results, row.names=NULL)
print(results)
}
else {
x <- readFASTA(inFile$datapath)
x <- x[(sapply(x, protcheck))]
ACC <- t(sapply(x, extractAAC))
test <- data.frame(ACC)
Prediction <- predict(fit, test)
Prediction <- as.data.frame(Prediction)
Protein <- cbind(Name = rownames(test, test))
results <- cbind(Protein, Prediction)
results <- data.frame(results, row.names=NULL)
print(results)
}
}
})
output$contents <- renderPrint({
if (input$submitbutton>0) {
isolate(datasetInput())
} else {
if (input$clearbutton>0) {
isolate(is.null(datasetInput()))
} else {
return("Please insert/upload sequence in FASTA format")
}
}
})
output$downloadData <- downloadHandler(
filename = function() { paste('Predicted_Results', '.csv', sep='') },
content = function(file) {
write.csv(datasetInput(), file, row.names=FALSE)
})
})