opt_home.R 21.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
createHeader <- function() {
  
  result <- ""
  
  if(input$containerType == "singularity") {
    result <- "Bootstrap: docker"
jlopez's avatar
jlopez committed
42
    result <- paste0(result, "\nFrom: ",  input$fromTemplate)
jlopez's avatar
jlopez committed
43
44
    result <- paste(result, "IncludeCmd: yes", sep = "\n")
  } else { # else docker
jlopez's avatar
jlopez committed
45
    result <- paste0("FROM ", input$fromTemplate)
jlopez's avatar
jlopez committed
46
  }
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
  Rversion = "3.4.3" 
  if(input$rtemplate == "source2") {
    Rversion = "3.4.4" 
  }else if(input$rtemplate == "source3") {
    Rversion = "3.5.0" 
  }
  
jlopez's avatar
jlopez committed
61
62
63
  if(input$containerType == "singularity") {
      result <- paste(result, "%environment", sep = "\n")
    
jlopez's avatar
Fix    
jlopez committed
64
      if(input$rtemplate == "none" || input$fromTemplate == "r-base") {
jlopez's avatar
jlopez committed
65
66
67
68
69
70
71
        
      } 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 {
jlopez's avatar
jlopez committed
72
73

        result <- paste0(result, "\n\tR_VERSION=", Rversion)
jlopez's avatar
jlopez committed
74
75
76
77
78
79
80
81
82
83
        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 {
jlopez's avatar
Fix    
jlopez committed
84
      if(input$rtemplate == "none" || input$fromTemplate == "r-base") {
jlopez's avatar
jlopez committed
85
86
        
      } else if(input$rtemplate == "base") {
jlopez's avatar
jlopez committed
87
        result <- paste0(result, "ENV R_VERSION=", Rversion)
jlopez's avatar
jlopez committed
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
        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")
jlopez's avatar
jlopez committed
113
        result <- paste(result, "\tAuthor YourName", sep = "\n")
jlopez's avatar
jlopez committed
114
115
116
        result <- paste(result, "\tVersion v0.0.1", sep = "\n")
        result <- paste0(result, "\n\tbuild_date ", format(Sys.time(), "%Y %b %d")) 
    } else {
jlopez's avatar
jlopez committed
117
      result <- paste(result, "LABEL Author YourName", sep = "\n")
jlopez's avatar
jlopez committed
118
119
120
121
122
123
124
125
126
      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
127
  
jlopez's avatar
jlopez committed
128
129
130
131
132
133
134
135
136
    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
137
  
jlopez's avatar
jlopez committed
138
139
140
141
142
    result <- paste0(result, "\n")
    return(result)
}

createLibPrePost <- function(result) {
jlopez's avatar
Proto  
jlopez committed
143
  
jlopez's avatar
jlopez committed
144
145
146
147
148
149
150
151
  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
152
  } else {
jlopez's avatar
jlopez committed
153
154
155
156
157
158
      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
159
160
      result <- paste(result, "ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64", sep = "\n")
      
jlopez's avatar
jlopez committed
161
162
  }
  
jlopez's avatar
jlopez committed
163
164
165
166
  result <- paste0(result, "\n")
  return(result)
}

jlopez's avatar
jlopez committed
167
#' Use for create install R from RBase content
jlopez's avatar
jlopez committed
168
169
createRBase <- function(result) {
  
jlopez's avatar
jlopez committed
170
171
  result <- paste(result, '############### Install R From RBase ##############', sep = "\n")
  
jlopez's avatar
jlopez committed
172
173
174
175
  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
176
177
  }
  
jlopez's avatar
jlopez committed
178
179
180
  result <- paste0(result, "\n")
  return(result)
}
jlopez's avatar
jlopez committed
181

jlopez's avatar
jlopez committed
182
#' Use for create install R from Source content
jlopez's avatar
jlopez committed
183
184
185
createRSource <- function(result, Rversion) {
  
  result <- paste(result, '############### Install R From Source ##############', sep = "\n")
jlopez's avatar
Proto  
jlopez committed
186
  
jlopez's avatar
jlopez committed
187
188
  if(input$containerType == "singularity") {
      result <- paste(result, '\tcd $HOME', sep = "\n")
jlopez's avatar
jlopez committed
189
190
191
      result <- paste0(result, '\n\twget https://cran.rstudio.com/src/base/R-3/R-', Rversion, '.tar.gz')
      result <- paste0(result, '\n\ttar xvf R-', Rversion, '.tar.gz')
      result <- paste0(result, '\n\tcd R-', Rversion)
jlopez's avatar
jlopez committed
192
193
194
195
196
      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")
jlopez's avatar
jlopez committed
197
198
199
    result <- paste0(result, '\n\t&& wget https://cran.rstudio.com/src/base/R-3/R-', Rversion, '.tar.gz \\')
    result <- paste0(result, '\n\t&& tar xvf R-', Rversion, '.tar.gz \\')
    result <- paste0(result, '\n\t&& cd R-', Rversion, ' \\')
jlopez's avatar
jlopez committed
200
201
202
203
    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
204
  
jlopez's avatar
jlopez committed
205
206
207
208
  result <- paste0(result, "\n")
  return(result)
}

jlopez's avatar
jlopez committed
209
#' Use for create install R from CRAN content
jlopez's avatar
jlopez committed
210
createRCran <- function(result) {
jlopez's avatar
Proto  
jlopez committed
211
  
jlopez's avatar
jlopez committed
212
213
  result <- paste(result, '############### Install R From CRAN ##############', sep = "\n")
  
jlopez's avatar
jlopez committed
214
215
216
217
218
219
220
221
222
223
224
225
226
  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
227
  
jlopez's avatar
jlopez committed
228
229
230
231
  result <- paste0(result, "\n")
  return(result)
}

jlopez's avatar
jlopez committed
232
#' Use for create CRAN content
jlopez's avatar
jlopez committed
233
createCRANPackage <- function(result) {
jlopez's avatar
Proto  
jlopez committed
234
  
jlopez's avatar
jlopez committed
235
236
  
  
jlopez's avatar
jlopez committed
237
238
239
  selectCRAN <- allCRAN[input$dtrcranpackage_rows_all,]
  selectCRAN <- selectCRAN[,"Package"]
  sizeCRAN <- length(selectCRAN)
jlopez's avatar
Proto  
jlopez committed
240
241
  
  
jlopez's avatar
jlopez committed
242
243
244
245
  if(!is.null(sizeCRAN)) {
    if(sizeCRAN < length(allCRAN[,"Package"])) { 
      if(sizeCRAN >= 1) { 
        
jlopez's avatar
jlopez committed
246
247
        result <- paste(result, '############### Install CRAN Package ##############', sep = "\n")
        
jlopez's avatar
jlopez committed
248
        if(input$containerType == "singularity") {
jlopez's avatar
jlopez committed
249
          listRCRAN <- '\tR --slave -e "install.packages( c('
jlopez's avatar
jlopez committed
250
        } else {
jlopez's avatar
jlopez committed
251
          listRCRAN <- 'RUN R --slave -e "install.packages( c('
jlopez's avatar
jlopez committed
252
253
254
255
        }
        
        for (pkg in 1:sizeCRAN){
          if(pkg < sizeCRAN) {
jlopez's avatar
jlopez committed
256
            listRCRAN <- paste0(listRCRAN, "'",selectCRAN[pkg],"', ")
jlopez's avatar
jlopez committed
257
          } else {
jlopez's avatar
jlopez committed
258
            listRCRAN <- paste0(listRCRAN, "'",selectCRAN[pkg],"'), repos='https://cloud.r-project.org'))\"")
jlopez's avatar
jlopez committed
259
260
261
262
263
264
265
266
          }
        }
        
        result <- paste(result, listRCRAN, sep = "\n")
        result <- paste0(result, "\n")
      }
    }
  }
jlopez's avatar
Proto  
jlopez committed
267
  
jlopez's avatar
jlopez committed
268
269
270
  return(result)
}

jlopez's avatar
jlopez committed
271
#' Use for create Github content
jlopez's avatar
jlopez committed
272
createGithubPackage <- function(result) {
jlopez's avatar
Proto  
jlopez committed
273
  
jlopez's avatar
jlopez committed
274
  if(!is.null(input$rgithubpackagelist)) {
jlopez's avatar
Proto  
jlopez committed
275
  
jlopez's avatar
jlopez committed
276
277
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
jlopez's avatar
jlopez committed
278
    
jlopez's avatar
jlopez committed
279
280
    if(sizeGITHUB >= 1) {
      
jlopez's avatar
jlopez committed
281
282
283
      result <- paste(result, '############### Install Github Package ##############', sep = "\n")
      
      
jlopez's avatar
jlopez committed
284
285
286
287
288
289
290
291
292
293
294
295
      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
296
        }
jlopez's avatar
jlopez committed
297
298
299
300
301
      }
      result <- paste(result, listRGITHUB, sep = "\n")
      
    }
  }
jlopez's avatar
Proto  
jlopez committed
302
  
jlopez's avatar
jlopez committed
303

jlopez's avatar
Fix bug    
jlopez committed
304
  
jlopez's avatar
jlopez committed
305
306
307
  result <- paste0(result, "\n")
  return(result)
}
jlopez's avatar
jlopez committed
308

jlopez's avatar
jlopez committed
309
#' Use for create Bioconductor content
jlopez's avatar
jlopez committed
310
createBioconductorPackage <- function(result) {
jlopez's avatar
jlopez committed
311
  
jlopez's avatar
jlopez committed
312
313
314
315
316
317
318
  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
319
        
jlopez's avatar
jlopez committed
320
321
322
        result <- paste(result, '############### Install Bioconductor Package ##############', sep = "\n")
        
        
jlopez's avatar
jlopez committed
323
324
325
326
327
328
        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
329
        }
jlopez's avatar
jlopez committed
330
      
jlopez's avatar
jlopez committed
331
332
333
334
335
336
337
        for (pkg in 1:sizeBIO){
          if(pkg < sizeBIO) {
            listRBIO <- paste0(listRBIO, '\'',selectBIO[pkg],'\', ')
          } else {
            listRBIO <- paste0(listRBIO, '\'',selectBIO[pkg],'\')"')
          }
        }
jlopez's avatar
jlopez committed
338
        
jlopez's avatar
jlopez committed
339
340
341
342
343
        result <- paste(result, listRBIO, sep = "\n")
        result <- paste0(result, "\n")
      }
    }
  }
jlopez's avatar
jlopez committed
344
  
jlopez's avatar
jlopez committed
345
346
  return(result)
}
jlopez's avatar
jlopez committed
347

jlopez's avatar
jlopez committed
348
#' Use for create Biocontainer content
jlopez's avatar
jlopez committed
349
createBiocontainer <- function(result, haveR) {
jlopez's avatar
jlopez committed
350

jlopez's avatar
jlopez committed
351
  if(input$containerType == "singularity") {
jlopez's avatar
jlopez committed
352
    selectBioTool <- input$selectedBiocontainer
jlopez's avatar
jlopez committed
353
354
355
356
    
    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
357
    result <- paste(result, "\tapt-get update", sep = "\n")
jlopez's avatar
jlopez committed
358
359
360
361
    
    result <- paste0(result, "\n")
    
    result <- paste(result, "\techo \'export PATH=/opt/conda/bin:$PATH\' > /etc/profile.d/conda.sh && \\",
jlopez's avatar
jlopez committed
362
363
364
                    "\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
365
366
    
    result <- paste0(result, "\n")
jlopez's avatar
jlopez committed
367
    
jlopez's avatar
jlopez committed
368
    result <- paste(result, "\tTINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o \"/v.*\\\"\" | sed \'s:^..\\(.*\\).$:\\1:\'` && \\",
jlopez's avatar
jlopez committed
369
370
371
372
                    "\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
373
374
375
    
    result <- paste0(result, "\n")
    
jlopez's avatar
jlopez committed
376
    result <- paste(result, "\tmkdir /opt/biotools", sep = "\n")
jlopez's avatar
jlopez committed
377
    result <- paste(result, "\tmkdir /opt/biotools/bin", sep = "\n")
jlopez's avatar
jlopez committed
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
    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
394
395
396
397
      
      result <- paste(result, '############### Install BioContainer tools ##############', sep = "\n")
      
      
jlopez's avatar
jlopez committed
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
      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
428
    result <- paste(result, "ENV PATH=/opt/biotools/bin:${PATH}", sep = "\n")
jlopez's avatar
jlopez committed
429
430
    
    result <- paste(result, "RUN chmod 777 -R /opt/conda/", sep = "\n")
jlopez's avatar
jlopez committed
431
    result <- paste(result, "ENV PATH=/opt/conda/bin:${PATH}", sep = "\n")
jlopez's avatar
jlopez committed
432
433
434
435
436
437
438
439
440
441
442
    
    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){
jlopez's avatar
jlopez committed
443
444
445
446
      
      result <- paste(result, '############### Install BioContainer tools ##############', sep = "\n")
      
      
jlopez's avatar
jlopez committed
447
      result <- paste0(result, "\nRUN ", getInstallToolPackageBioContainer(tool, input$containerType))
jlopez's avatar
jlopez committed
448
    }
jlopez's avatar
jlopez committed
449
    
jlopez's avatar
jlopez committed
450
451
  }
  
jlopez's avatar
jlopez committed
452
453
454
455
    result <- paste0(result, "\n")
    return(result)
}

jlopez's avatar
jlopez committed
456
#' Use for create Singularity or Dockerfile
jlopez's avatar
jlopez committed
457
458
459
460
461
462
463
464
465
createContentFile <- function() {
  
  haveR = FALSE

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

jlopez's avatar
Fix    
jlopez committed
466
  if(input$rtemplate != "none" && input$fromTemplate != "r-base") {
jlopez's avatar
jlopez committed
467
468
469
    
      haveR = TRUE
    
jlopez's avatar
jlopez committed
470
471
472
473
474
475
476
477
478
      if(input$rtemplate == "source" || input$rtemplate == "source2" || input$rtemplate == "source3") {
          Rversion = "3.4.3" 
          if(input$rtemplate == "source2") {
            Rversion = "3.4.4" 
          }else if(input$rtemplate == "source3") {
            Rversion = "3.5.0" 
          }
        
          result <- createRSource(result, Rversion)
jlopez's avatar
jlopez committed
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
      } 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
495
  
jlopez's avatar
Proto  
jlopez committed
496
  result <- paste(result, input$customDataContainer, sep = "\t\n")
jlopez's avatar
jlopez committed
497
  
jlopez's avatar
Proto  
jlopez committed
498
499
500
  return(result)
}

jlopez's avatar
jlopez committed
501
observeEvent(input$createContainer, {
jlopez's avatar
jlopez committed
502
503

  js$collapse("boxPackage")
jlopez's avatar
Proto  
jlopez committed
504
505
506
  
  show("downloadContainerFile")
  
jlopez's avatar
jlopez committed
507
508
509
510
511
512
  result <- createContentFile()
  
  updateTextAreaInput(session, "previewContainer",
                      label = "",
                      value = result)
  
jlopez's avatar
Proto  
jlopez committed
513
514
})

jlopez's avatar
jlopez committed
515
#createContainerPackage <- eventReactive(input$createContainer, {
jlopez's avatar
Proto  
jlopez committed
516

jlopez's avatar
jlopez committed
517
518
519
520
  #result <- createContentFile()
  
  #show("downloadContainerFile")
  
jlopez's avatar
Proto  
jlopez committed
521

jlopez's avatar
jlopez committed
522
523
524
525
526
527
528
529
530
  #HTML(result)

#})



#output$previewContainer <- renderText({
#  createContainerPackage()
#})
jlopez's avatar
Proto  
jlopez committed
531

jlopez's avatar
jlopez committed
532

jlopez's avatar
Proto  
jlopez committed
533
534
output$downloadContainerFile <- downloadHandler(
  filename = function() {
jlopez's avatar
jlopez committed
535
536
537
538
539
540
    name <- ""
    if(input$containerType == "singularity") {
      name <- paste("Singularity",input$imageName, sep = ".")
    } else {
      name <- paste("Dockerfile",input$imageName, sep = ".")
    }
jlopez's avatar
Proto  
jlopez committed
541
542
  },
  content = function(file) {
jlopez's avatar
jlopez committed
543
    result <- input$previewContainer
jlopez's avatar
Proto  
jlopez committed
544
545
546
547
    write(result,file=file)
  }
)

jlopez's avatar
jlopez committed
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
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
564
565
566
567
568
569

observe({
  if(is.null(input$dtrgithubpackage_rows_selected)) {
    
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
jlopez's avatar
jlopez committed
570
    
jlopez's avatar
jlopez committed
571
572
573
574
575
576
577
578
579
580
    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
581
    }
jlopez's avatar
jlopez committed
582
    selectG <- c(unlist(selectG))
jlopez's avatar
jlopez committed
583
    
jlopez's avatar
jlopez committed
584
585
586
587
588
589
    selectGithub <- input$rgithubpackagelist
    sizeGITHUB <- length(selectGithub)
    
    if(sizeGITHUB > 1) {
      selectG <- c(selectG, selectGithub)
    }
jlopez's avatar
jlopez committed
590
  
jlopez's avatar
jlopez committed
591
592
    updateSelectizeInput(session,"rgithubpackagelist", choices = selectG, selected = selectG, options = list())
  }
jlopez's avatar
jlopez committed
593
})
jlopez's avatar
jlopez committed
594
595
596
597
598
599
600
601

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
602
    if(length(allGITHUB)  >= 1 ) {
jlopez's avatar
jlopez committed
603
604
605
606
    output$dtrgithubpackage <- DT::renderDataTable({
      result <- allGITHUB
      return(result)
    }, filter='top', escape = FALSE, rownames= FALSE,server = TRUE)
jlopez's avatar
jlopez committed
607
    }
jlopez's avatar
jlopez committed
608
609
610
611
612
  }
  
})