opt_home.R 19.1 KB
Newer Older
jlopez's avatar
Proto  
jlopez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

output$dtrcranpackage <- DT::renderDataTable({
  
  
  result <- allCRAN
  
  return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)

output$dtrbioconductorpackage <- DT::renderDataTable({
  result <- allBIO
  
  return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)

output$dtrgithubpackage <- DT::renderDataTable({
  result <- data.frame(Package=character(),
                             Version=character())
  
  return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)

jlopez's avatar
jlopez committed
23
24
25
26
27
28
29
30
31
32
33
34
35
output$dtbiocontainer <- DT::renderDataTable({
  result <- data.frame(Tool=character(),
                       Version=character(),
                       Description=character())

  result <- getBioconductorPackage()
  
  
  return(result)
}, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)



jlopez's avatar
jlopez committed
36
37
38
39
40
41
42
43
44
45
46
createHeader <- function() {
  
  result <- ""
  
  if(input$containerType == "singularity") {
    result <- "Bootstrap: docker"
    result <- paste(result, "From: ubuntu:16.04", sep = "\n")
    result <- paste(result, "IncludeCmd: yes", sep = "\n")
  } else { # else docker
    result <- "FROM ubuntu:16.04"
  }
jlopez's avatar
jlopez committed
47

jlopez's avatar
jlopez committed
48
49
50
  result <- paste0(result, "\n")
  return(result)
}
jlopez's avatar
Proto  
jlopez committed
51

jlopez's avatar
jlopez committed
52
createEnv <- function(result) {
jlopez's avatar
jlopez committed
53
  
jlopez's avatar
jlopez committed
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
108
109
110
111
112
113
114
115
116
117
118
  if(input$containerType == "singularity") {
      result <- paste(result, "%environment", sep = "\n")
    
      if(input$rtemplate == "none") {
        
      } else if(input$rtemplate == "base") {
        result <- paste(result, "\tR_VERSION=3.2.5", sep = "\n")
        result <- paste(result, "\texport R_VERSION", sep = "\n")
        result <- paste(result, "\tR_CONFIG_DIR=/etc/R/", sep = "\n")
        result <- paste(result, "\texport R_CONFIG_DIR", sep = "\n")
      } else {
        result <- paste(result, "\tR_VERSION=3.4.3", sep = "\n")
        result <- paste(result, "\texport R_VERSION", sep = "\n")
        result <- paste(result, "\tR_CONFIG_DIR=/etc/R/", sep = "\n")
        result <- paste(result, "\texport R_CONFIG_DIR", sep = "\n")
      }
      
      if(!is.null(input$dtbiocontainer_rows_all)) {
        result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n")
        result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n")
      }
  } else {
      if(input$rtemplate == "none") {
        
      } else if(input$rtemplate == "base") {
        result <- paste(result, "ENV R_VERSION=3.4.3", sep = "\n")
        result <- paste(result, "RUN export R_VERSION", sep = "\n")
        result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n")
        result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n")
        
      } else {
        result <- paste(result, "ENV R_VERSION=3.4.3", sep = "\n")
        result <- paste(result, "RUN export R_VERSION", sep = "\n")
        result <- paste(result, "ENV R_CONFIG_DIR=/etc/R/", sep = "\n")
        result <- paste(result, "RUN export R_CONFIG_DIR", sep = "\n")
      }
      
      if(!is.null(input$dtbiocontainer_rows_all)) {
        result <- paste(result, "RUN export PATH=/opt/conda/bin:$PATH", sep = "\n")
        result <- paste(result, "RUN export PATH=/opt/biotools/bin:$PATH", sep = "\n")
      }
  }

  result <- paste0(result, "\n")
  return(result)
}

createLabel <- function(result) {
  
    if(input$containerType == "singularity") {
        result <- paste(result, "%labels", sep = "\n")
        result <- paste(result, "\tAuthor Jimmy Lopez", sep = "\n")
        result <- paste(result, "\tVersion v0.0.1", sep = "\n")
        result <- paste0(result, "\n\tbuild_date ", format(Sys.time(), "%Y %b %d")) 
    } else {
      result <- paste(result, "LABEL Author Jimmy Lopez", sep = "\n")
      result <- paste(result, "LABEL Version v0.0.1", sep = "\n")
      result <- paste0(result, "\n", "LABEL build_date ", format(Sys.time(), "%Y %b %d")) 
    }

    result <- paste0(result, "\n")
    return(result)
}

createExect <- function(result) {
jlopez's avatar
jlopez committed
119
  
jlopez's avatar
jlopez committed
120
121
122
123
124
125
126
127
128
    if(input$containerType == "singularity") {
        result <- paste(result, "%apprun run", sep = "\n")
        result <- paste(result, '\texec /bin/bash "$@"', sep = "\n")
        result <- paste0(result, "\n")
        result <- paste(result, "%runscript", sep = "\n")
        result <- paste(result, '\texec /bin/bash "$@"', sep = "\n")
    } else {
        result <- paste(result, "CMD exec /bin/bash \"$@\"", sep = "\n")
    }
jlopez's avatar
Proto  
jlopez committed
129
  
jlopez's avatar
jlopez committed
130
131
132
133
134
    result <- paste0(result, "\n")
    return(result)
}

createLibPrePost <- function(result) {
jlopez's avatar
Proto  
jlopez committed
135
  
jlopez's avatar
jlopez committed
136
137
138
139
140
141
142
143
  if(input$containerType == "singularity") {
      result <- paste(result, "%post", sep = "\n")
      result <- paste(result, "\tapt-get update", sep = "\n")
      result <- paste(result, "\tapt-get install -y wget libblas3 libblas-dev liblapack-dev liblapack3 curl", sep = "\n")
      result <- paste(result, "\tapt-get install -y gcc fort77 aptitude", sep = "\n")
      result <- paste(result, "\taptitude install -y g++ xorg-dev libreadline-dev  gfortran", sep = "\n")
      result <- paste(result, "\tapt-get install -y libssl-dev libxml2-dev libpcre3-dev liblzma-dev libbz2-dev libcurl4-openssl-dev", sep = "\n")
      result <- paste(result, "\tapt-get update", sep = "\n")
jlopez's avatar
jlopez committed
144
  } else {
jlopez's avatar
jlopez committed
145
146
147
148
149
150
      result <- paste(result, "RUN apt-get update", sep = "\n")
      result <- paste(result, "RUN apt-get install -y wget libblas3 libblas-dev liblapack-dev liblapack3 curl", sep = "\n")
      result <- paste(result, "RUN apt-get install -y gcc fort77 aptitude", sep = "\n")
      result <- paste(result, "RUN aptitude install -y g++ xorg-dev libreadline-dev  gfortran", sep = "\n")
      result <- paste(result, "RUN apt-get install -y libssl-dev libxml2-dev libpcre3-dev liblzma-dev libbz2-dev libcurl4-openssl-dev openjdk-8-jre", sep = "\n")
      result <- paste(result, "RUN apt-get update", sep = "\n")
jlopez's avatar
jlopez committed
151
152
      result <- paste(result, "ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64", sep = "\n")
      
jlopez's avatar
jlopez committed
153
154
  }
  
jlopez's avatar
jlopez committed
155
156
157
158
159
160
161
162
163
164
  result <- paste0(result, "\n")
  return(result)
}

createRBase <- function(result) {
  
  if(input$containerType == "singularity") {
      result <- paste(result, "\tapt-get install -y r-base r-base-dev", sep = "\n")
  } else {
    result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n")
jlopez's avatar
jlopez committed
165
166
  }
  
jlopez's avatar
jlopez committed
167
168
169
  result <- paste0(result, "\n")
  return(result)
}
jlopez's avatar
jlopez committed
170

jlopez's avatar
jlopez committed
171
createRSource <- function(result) {
jlopez's avatar
Proto  
jlopez committed
172
  
jlopez's avatar
jlopez committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  if(input$containerType == "singularity") {
      result <- paste(result, '\tcd $HOME', sep = "\n")
      result <- paste(result, '\twget https://cran.rstudio.com/src/base/R-3/R-3.4.3.tar.gz', sep = "\n")
      result <- paste(result, '\ttar xvf R-3.4.3.tar.gz', sep = "\n")
      result <- paste(result, '\tcd R-3.4.3', sep = "\n")
      result <- paste(result, "\t./configure --enable-R-static-lib --with-blas --with-lapack --enable-R-shlib=yes ", sep = "\n") 
      result <- paste(result, "\tmake", sep = "\n") 
      result <- paste(result, "\tmake install", sep = "\n") 
  } else {
    result <- paste(result, 'RUN cd $HOME \\', sep = "\n")
    result <- paste(result, '\t&& wget https://cran.rstudio.com/src/base/R-3/R-3.4.3.tar.gz \\', sep = "\n")
    result <- paste(result, '\t&& tar xvf R-3.4.3.tar.gz \\', sep = "\n")
    result <- paste(result, '\t&& cd R-3.4.3 \\' , sep = "\n")
    result <- paste(result, "\t&& ./configure --enable-R-static-lib --with-blas --with-lapack --enable-R-shlib=yes \\", sep = "\n") 
    result <- paste(result, "\t&& make \\", sep = "\n") 
    result <- paste(result, "\t&& make install \\", sep = "\n") 
  }
jlopez's avatar
Proto  
jlopez committed
190
  
jlopez's avatar
jlopez committed
191
192
193
194
195
  result <- paste0(result, "\n")
  return(result)
}

createRCran <- function(result) {
jlopez's avatar
Proto  
jlopez committed
196
  
jlopez's avatar
jlopez committed
197
198
199
200
201
202
203
204
205
206
207
208
209
  if(input$containerType == "singularity") {
      result <- paste(result, "\tapt-get install -y software-properties-common", sep = "\n")
      result <- paste(result, "\tadd-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial/'", sep = "\n")
      result <- paste(result, "\tapt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9", sep = "\n")
      result <- paste(result, "\tapt-get update", sep = "\n")
      result <- paste(result, "\tapt-get install -y r-base r-base-dev", sep = "\n")
  } else {
      result <- paste(result, "RUN apt-get install -y software-properties-common", sep = "\n")
      result <- paste(result, "RUN add-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial/'", sep = "\n")
      result <- paste(result, "RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9", sep = "\n")
      result <- paste(result, "RUN apt-get update", sep = "\n")
      result <- paste(result, "RUN apt-get install -y r-base r-base-dev", sep = "\n")
  }
jlopez's avatar
Proto  
jlopez committed
210
  
jlopez's avatar
jlopez committed
211
212
213
214
215
  result <- paste0(result, "\n")
  return(result)
}

createCRANPackage <- function(result) {
jlopez's avatar
Proto  
jlopez committed
216
  
jlopez's avatar
jlopez committed
217
218
219
  selectCRAN <- allCRAN[input$dtrcranpackage_rows_all,]
  selectCRAN <- selectCRAN[,"Package"]
  sizeCRAN <- length(selectCRAN)
jlopez's avatar
Proto  
jlopez committed
220
221
  
  
jlopez's avatar
jlopez committed
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  if(!is.null(sizeCRAN)) {
    if(sizeCRAN < length(allCRAN[,"Package"])) { 
      if(sizeCRAN >= 1) { 
        
        if(input$containerType == "singularity") {
          listRCRAN <- '\techo install.packages\\(c('
        } else {
          listRCRAN <- 'RUN echo install.packages\\(c('
        }
        
        for (pkg in 1:sizeCRAN){
          if(pkg < sizeCRAN) {
            listRCRAN <- paste0(listRCRAN, '"',selectCRAN[pkg],'", ')
          } else {
            listRCRAN <- paste0(listRCRAN, '"',selectCRAN[pkg],'"), repos\\=\'https://cloud.r-project.org\'\\) | R --slave ')
          }
        }
        
        result <- paste(result, listRCRAN, sep = "\n")
        result <- paste0(result, "\n")
      }
    }
  }
jlopez's avatar
Proto  
jlopez committed
245
  
jlopez's avatar
jlopez committed
246
247
248
249
  return(result)
}

createGithubPackage <- function(result) {
jlopez's avatar
Proto  
jlopez committed
250
  
jlopez's avatar
jlopez committed
251
  if(!is.null(input$rgithubpackagelist)) {
jlopez's avatar
Proto  
jlopez committed
252
  
jlopez's avatar
jlopez committed
253
254
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
jlopez's avatar
jlopez committed
255
    
jlopez's avatar
jlopez committed
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    if(sizeGITHUB >= 1) {
      
      if(input$containerType == "singularity") {
        listRGITHUB <- '\tR --slave -e "install_github(c('
      } else {
        listRGITHUB <- 'RUN R --slave -e "install_github(c('
      }
      
      
      for (pkg in 1:sizeGITHUB){
        if(pkg < sizeGITHUB) {
          listRGITHUB <- paste0(listRGITHUB, '\'',selectGithub[pkg],'\', ')
        } else {
          listRGITHUB <- paste0(listRGITHUB, '\'',selectGithub[pkg],'\'))"')
jlopez's avatar
jlopez committed
270
        }
jlopez's avatar
jlopez committed
271
272
273
274
275
      }
      result <- paste(result, listRGITHUB, sep = "\n")
      
    }
  }
jlopez's avatar
Proto  
jlopez committed
276
  
jlopez's avatar
jlopez committed
277

jlopez's avatar
Fix bug    
jlopez committed
278
  
jlopez's avatar
jlopez committed
279
280
281
  result <- paste0(result, "\n")
  return(result)
}
jlopez's avatar
jlopez committed
282

jlopez's avatar
jlopez committed
283
createBioconductorPackage <- function(result) {
jlopez's avatar
jlopez committed
284
  
jlopez's avatar
jlopez committed
285
286
287
288
289
290
291
  selectBIO <- allBIO[input$dtrbioconductorpackage_rows_all,]
  selectBIO <- selectBIO[,"Package"]
  sizeBIO <- length(selectBIO)
  
  if(!is.null(sizeBIO)) {
    if(sizeBIO < length(allBIO[,"Package"])) { 
      if(sizeBIO >= 1) { 
jlopez's avatar
jlopez committed
292
        
jlopez's avatar
jlopez committed
293
294
295
296
297
298
        if(input$containerType == "singularity") {
          result <- paste(result, '\tR --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(); "', sep = "\n")
          listRBIO <- '\tR --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(\\'
        } else {
          result <- paste(result, 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(); "', sep = "\n")
          listRBIO <- 'RUN R --slave -e "source(\'https://bioconductor.org/biocLite.R\'); biocLite(\\'
jlopez's avatar
jlopez committed
299
        }
jlopez's avatar
jlopez committed
300
      
jlopez's avatar
jlopez committed
301
302
303
304
305
306
307
        for (pkg in 1:sizeBIO){
          if(pkg < sizeBIO) {
            listRBIO <- paste0(listRBIO, '\'',selectBIO[pkg],'\', ')
          } else {
            listRBIO <- paste0(listRBIO, '\'',selectBIO[pkg],'\')"')
          }
        }
jlopez's avatar
jlopez committed
308
        
jlopez's avatar
jlopez committed
309
310
311
312
313
        result <- paste(result, listRBIO, sep = "\n")
        result <- paste0(result, "\n")
      }
    }
  }
jlopez's avatar
jlopez committed
314
  
jlopez's avatar
jlopez committed
315
316
  return(result)
}
jlopez's avatar
jlopez committed
317

jlopez's avatar
jlopez committed
318
createBiocontainer <- function(result, haveR) {
jlopez's avatar
jlopez committed
319

jlopez's avatar
jlopez committed
320
  if(input$containerType == "singularity") {
jlopez's avatar
jlopez committed
321
    selectBioTool <- input$selectedBiocontainer
jlopez's avatar
jlopez committed
322
323
324
325
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "\tapt-get install -y  autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev", sep = "\n")
jlopez's avatar
jlopez committed
326
    result <- paste(result, "\tapt-get update", sep = "\n")
jlopez's avatar
jlopez committed
327
328
329
330
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "\techo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\",
jlopez's avatar
jlopez committed
331
332
333
                    "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ~/miniconda.sh && \\",
                    "\t/bin/bash ~/miniconda.sh -b -p /opt/conda && \\",
                    "\trm ~/miniconda.sh", sep = "\n")
jlopez's avatar
jlopez committed
334
335
    
    result <- paste0(result, "\n")
jlopez's avatar
jlopez committed
336
    
jlopez's avatar
jlopez committed
337
    result <- paste(result, "\tTINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o \"/v.*\\\"\" | sed \'s:^..\\(.*\\).$:\\1:\'` && \\",
jlopez's avatar
jlopez committed
338
339
340
341
                    "\tcurl -L \"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb\" > tini.deb && \\",
                    "\tdpkg -i tini.deb && \\",
                    "\trm tini.deb && \\",
                    "\tapt-get clean", sep = "\n")
jlopez's avatar
jlopez committed
342
343
344
    
    result <- paste0(result, "\n")
    
jlopez's avatar
jlopez committed
345
    result <- paste(result, "\tmkdir /opt/biotools", sep = "\n")
jlopez's avatar
jlopez committed
346
    result <- paste(result, "\tmkdir /opt/biotools/bin", sep = "\n")
jlopez's avatar
jlopez committed
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
    result <- paste(result, "\tchmod 777 -R /opt/biotools/", sep = "\n")
    result <- paste(result, "\texport PATH=/opt/biotools/bin:$PATH", sep = "\n")
    
    result <- paste(result, "\tchmod 777 -R /opt/conda/", sep = "\n")
    result <- paste(result, "\texport PATH=/opt/conda/bin:$PATH", sep = "\n")
    
    if(!haveR) {
      result <- paste(result, "\tconda config --add channels r", sep = "\n")
    }
    
    result <- paste(result, "\tconda config --add channels bioconda", sep = "\n")
    result <- paste(result, "\tconda upgrade conda", sep = "\n")
    
    result <- paste0(result, "\n")
    
    for (tool in selectBioTool){
jlopez's avatar
jlopez committed
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
      result <- paste(result, getInstallToolPackageBioContainer(tool, input$containerType), sep="\n\n")
    }
  } else {
    selectBioTool <- input$selectedBiocontainer
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "RUN apt-get install -y  autotools-dev automake cmake curl grep sed dpkg fuse git zip openjdk-8-jre build-essential pkg-config python python-dev python-pip bzip2 ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 mercurial subversion zlib1g-dev", sep = "\n")
    result <- paste(result, "RUN apt-get update", sep = "\n")
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "RUN echo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\",
                    "\twget --quiet https://repo.continuum.io/miniconda/Miniconda2-4.0.5-Linux-x86_64.sh -O ~/miniconda.sh && \\",
                    "\t/bin/bash ~/miniconda.sh -b -p /opt/conda && \\",
                    "\trm ~/miniconda.sh", sep = "\n")
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "RUN TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o \"/v.*\\\"\" | sed \'s:^..\\(.*\\).$:\\1:\'` && \\",
                    "\tcurl -L \"https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb\" > tini.deb && \\",
                    "\tdpkg -i tini.deb && \\",
                    "\trm tini.deb && \\",
                    "\tapt-get clean", sep = "\n")
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "RUN mkdir /opt/biotools", sep = "\n")
    result <- paste(result, "RUN mkdir /opt/biotools/bin", sep = "\n")
    result <- paste(result, "RUN chmod 777 -R /opt/biotools/", sep = "\n")
jlopez's avatar
jlopez committed
393
    result <- paste(result, "ENV PATH=/opt/biotools/bin:${PATH}", sep = "\n")
jlopez's avatar
jlopez committed
394
395
    
    result <- paste(result, "RUN chmod 777 -R /opt/conda/", sep = "\n")
jlopez's avatar
jlopez committed
396
    result <- paste(result, "ENV PATH=/opt/conda/bin:${PATH}", sep = "\n")
jlopez's avatar
jlopez committed
397
398
399
400
401
402
403
404
405
406
407
408
    
    if(!haveR) {
      result <- paste(result, "RUN conda config --add channels r", sep = "\n")
    }
    
    result <- paste(result, "RUN conda config --add channels bioconda", sep = "\n")
    result <- paste(result, "RUN conda upgrade conda", sep = "\n")
    
    result <- paste0(result, "\n")
    
    for (tool in selectBioTool){
      result <- paste0(result, "\nRUN ", getInstallToolPackageBioContainer(tool, input$containerType))
jlopez's avatar
jlopez committed
409
    }
jlopez's avatar
jlopez committed
410
    
jlopez's avatar
jlopez committed
411
412
  }
  
jlopez's avatar
jlopez committed
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
    result <- paste0(result, "\n")
    return(result)
}

createContentFile <- function() {
  
  haveR = FALSE

  result <- createHeader()
  result <- createEnv(result)
  result <- createLabel(result)
  result <- createLibPrePost(result)

  if(input$rtemplate != "none") {
    
      haveR = TRUE
    
      if(input$rtemplate == "source") {
          result <- createRSource(result)
      } else if(input$rtemplate == "base") {
          result <- createRBase(result)
      } else if(input$rtemplate == "cran") {
          result <- createRCran(result)
      }
      
      result <- createCRANPackage(result)
      result <- createBioconductorPackage(result)
      result <- createGithubPackage(result)
  } 

  if(!is.null(input$selectedBiocontainer)) {
    result <- createBiocontainer(result, haveR)
  }
  
  result <- createExect(result)
jlopez's avatar
jlopez committed
448
  
jlopez's avatar
Proto  
jlopez committed
449
  result <- paste(result, input$customDataContainer, sep = "\t\n")
jlopez's avatar
jlopez committed
450
  
jlopez's avatar
Proto  
jlopez committed
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
  return(result)
}

createContainerPackage <- eventReactive(input$createContainer, {

  result <- createContentFile()
  
  show("downloadContainerFile")
  
  HTML(result)
})



output$previewContainer <- renderText({
  createContainerPackage()
})

output$downloadContainerFile <- downloadHandler(
  filename = function() {
jlopez's avatar
jlopez committed
471
472
473
474
475
476
    name <- ""
    if(input$containerType == "singularity") {
      name <- paste("Singularity",input$imageName, sep = ".")
    } else {
      name <- paste("Dockerfile",input$imageName, sep = ".")
    }
jlopez's avatar
Proto  
jlopez committed
477
478
479
480
481
482
483
  },
  content = function(file) {
    result <- createContentFile()
    write(result,file=file)
  }
)

jlopez's avatar
jlopez committed
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
observe({
  
  if(is.null(input$dtbiocontainer_rows_selected)) {
    shinyjs::reset("formContainer")
  } else {
    i = 1
    selectBiocontainer <- list()
    for(x in input$dtbiocontainer_rows_selected) {
      selectBiocontainer[i] = paste(allBIOCONTAINER[[x]]$name, allBIOCONTAINER[[x]]$version, sep = "%")
      i = i + 1
    }
    selectBiocontainer <- c(unlist(selectBiocontainer))
    updateSelectizeInput(session,"selectedBiocontainer", choices = selectBiocontainer, selected = selectBiocontainer, options = list())
  }
})

jlopez's avatar
jlopez committed
500
501
502
503
504
505

observe({
  if(is.null(input$dtrgithubpackage_rows_selected)) {
    
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
jlopez's avatar
jlopez committed
506
    
jlopez's avatar
jlopez committed
507
508
509
510
511
512
513
514
515
516
    if(sizeGITHUB < 1) {
      shinyjs::reset("formGithub")
    }

  } else {
    i = 1
    selectG <- list()
    for(x in input$dtrgithubpackage_rows_selected) {
      selectG[i] = toString(allGITHUB$Package[[x]])
      i = i + 1
jlopez's avatar
jlopez committed
517
    }
jlopez's avatar
jlopez committed
518
    selectG <- c(unlist(selectG))
jlopez's avatar
jlopez committed
519
    
jlopez's avatar
jlopez committed
520
521
522
523
524
525
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
    
    if(sizeGITHUB > 1) {
      selectG <- c(selectG, selectGithub)
    }
jlopez's avatar
jlopez committed
526
  
jlopez's avatar
jlopez committed
527
528
    updateSelectizeInput(session,"rgithubpackagelist", choices = selectG, selected = selectG, options = list())
  }
jlopez's avatar
jlopez committed
529
})
jlopez's avatar
jlopez committed
530
531
532
533
534
535
536
537

observeEvent(input$findGithub, {
  
  name <- input$inputGithub
  
  if(!stri_isempty(name)) {
    allGITHUB <<- data.frame(Package = gh_suggest(name, keep_title = FALSE), Title = attr(gh_suggest(name, keep_title = TRUE), "title"))
    
jlopez's avatar
jlopez committed
538
    if(length(allGITHUB)  >= 1 ) {
jlopez's avatar
jlopez committed
539
540
541
542
    output$dtrgithubpackage <- DT::renderDataTable({
      result <- allGITHUB
      return(result)
    }, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)
jlopez's avatar
jlopez committed
543
    }
jlopez's avatar
jlopez committed
544
545
546
547
548
  }
  
})