helper_functions.R 4.43 KB
Newer Older
jlopez's avatar
Fix bug    
jlopez committed
1
getPackagesWithTitle <- function() {
jlopez's avatar
Fix bug    
jlopez committed
2
       contrib.url("https://cran.rstudio.com/", "source") 
jlopez's avatar
Fix bug    
jlopez committed
3
       description <- sprintf("%s/web/packages/packages.rds", 
jlopez's avatar
Fix bug    
jlopez committed
4
                              "https://cran.rstudio.com/")
jlopez's avatar
Fix bug    
jlopez committed
5
6
7
8
9
10
11
12
13
14
15
16
       con <- if(substring(description, 1L, 7L) == "file://") {
            file(description, "rb")
         } else {
              url(description, "rb")
           }
     on.exit(close(con))
       db <- readRDS(gzcon(con))
       rownames(db) <- NULL
  
         db[, c("Package", "Title", "Version")]
   }

jlopez's avatar
jlopez committed
17

jlopez's avatar
jlopez committed
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
getWorkflows <- function() {
  
  data <- allWORKFLOWS
  
  size <- 0 
  
  for (tools in data) {
    if(length(tools$install) > 0) {
      size <- size + 1
    }
  }
  
  Tool <- character(size)
  Version <- character(size)
  Author <- character(size)
  Description <- character(size)
  Link <- character(size)
  
  i=1
  for (tools in data) {
    Tool[i] = tools$name
    Version[i] = tools$version
    Author[i] = tools$author
    Description[i] = tools$description
    Link[i] = paste0("<a href='", tools$documentation, "'>documentation</a>")
    i = i + 1
  }

  
  result <- data.frame(Workflow=Tool,
                       Version=Version,
                       Author=Author,
                       Description=Description,
                       Link=Link)
  
  return(result)
  
  
}
jlopez's avatar
jlopez committed
57
58
59


getBioconductorPackage <- function() {
jlopez's avatar
jlopez committed
60

jlopez's avatar
jlopez committed
61
  data <- allBIOCONTAINER
jlopez's avatar
jlopez committed
62
  
jlopez's avatar
jlopez committed
63
  size <- 0 
jlopez's avatar
jlopez committed
64
  
jlopez's avatar
jlopez committed
65
66
67
68
69
  for (tools in data) {
    if(length(tools$install) > 0) {
      size <- size + 1
    }
  }
jlopez's avatar
jlopez committed
70
  
jlopez's avatar
jlopez committed
71
72
73
74
75
76
77
78
  Tool <- character(size)
  Version <- character(size)
  Description <- character(size)
  Link <- character(size)

  i=1
  for (tools in data) {
    
jlopez's avatar
jlopez committed
79
    #if(length(tools$install) > 0) {
jlopez's avatar
jlopez committed
80
81
82
83
84
85
    
    Tool[i] = tools$name
    Version[i] = tools$version
    Description[i] = tools$description
    Link[i] = paste0("<a href='", tools$documentation, "'>documentation</a>")
    i = i + 1
jlopez's avatar
jlopez committed
86
    #}
jlopez's avatar
jlopez committed
87
  }
jlopez's avatar
jlopez committed
88
  
jlopez's avatar
jlopez committed
89
90
91
92
93
  # Link = c("<a href='https://github.com/r78v10a07/DiffExpIR'>documentation</a>",
  #          "<a href='https://github.com/bcgsc/abyss#abyss'>documentation</a>",
  #          "<a href='https://www.zfmk.de/dateien/atoms/files/aliscore_v.2.0_manual_0.pdf'>documentation</a>"
  #          
  # )
jlopez's avatar
jlopez committed
94
95
96
97
  
  result <- data.frame(BioContainer_Tool=Tool,
                       Version=Version,
                       Description=Description,
jlopez's avatar
jlopez committed
98
                       Link=Link)
jlopez's avatar
jlopez committed
99
100
101
102
  
  return(result)
}

jlopez's avatar
jlopez committed
103
104
105
106
107
108
109
getInstallToolPackageWorkflow <- function(tool, containerType) {
  
  data <- allWORKFLOWS
  
  size <- length(data)
  
  intalls <- ""
jlopez's avatar
jlopez committed
110
  res <- c()
jlopez's avatar
jlopez committed
111
112
113
114
115
116
117
118
119
120
  
  for (tools in data) {
    splitB <- strsplit(tool, "%")  
    name <- splitB[[1]][1]
    version <- splitB[[1]][2]
    
    if(tools$name == name) {
      if(tools$version == version) {
        for (c in tools$dependencies) {
          tt <- paste0(c$name, "%", c$version)
jlopez's avatar
jlopez committed
121
          res <- c(res, getInstallToolPackageBioContainer(tt, containerType))
jlopez's avatar
jlopez committed
122
        }
jlopez's avatar
jlopez committed
123
124
        res <- c(res, paste0("\t", tools$install, collapse='\n' ))
        print(res)
jlopez's avatar
jlopez committed
125
126
127
128
129
130
131
132
133
        return(res)
      }
    }
  }
  
  return("\t")
  
}

jlopez's avatar
jlopez committed
134
getInstallToolPackageBioContainer <- function(tool, containerType) {
jlopez's avatar
jlopez committed
135
  
jlopez's avatar
jlopez committed
136
  data <- allBIOCONTAINER
jlopez's avatar
jlopez committed
137
138

  size <- length(data)
jlopez's avatar
jlopez committed
139
  
jlopez's avatar
jlopez committed
140
  intalls <- ""
jlopez's avatar
jlopez committed
141
  
jlopez's avatar
jlopez committed
142
  for (tools in data) {
jlopez's avatar
jlopez committed
143
144
145
146
147
148
      splitB <- strsplit(tool, "%")  
      name <- splitB[[1]][1]
      version <- splitB[[1]][2]
      
      if(tools$name == name) {
        if(tools$version == version) {
jlopez's avatar
jlopez committed
149
150
151
          
                      
          
jlopez's avatar
jlopez committed
152
          res <- paste0("\t", tools$install, collapse='\n' )
jlopez's avatar
jlopez committed
153
154
155
          return(res)
        }
      }
jlopez's avatar
jlopez committed
156
157
158
159
  }

  return("\t")

jlopez's avatar
jlopez committed
160
161
}

jlopez's avatar
jlopez committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
getInstallToolEnvBioContainer <- function(tool, containerType) {
  
  data <- allBIOCONTAINER
  
  size <- length(data)
  
  intalls <- ""
  
  for (tools in data) {
    splitB <- strsplit(tool, "%")  
    name <- splitB[[1]][1]
    version <- splitB[[1]][2]
    
    if(tools$name == name) {
      if(tools$version == version) {
        if(is.null(tools$env)) {
          return (FALSE)
        } else {
          return(tools$env)
        }
      }
    }
  }
  
  return (FALSE)
}

jlopez's avatar
jlopez committed
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
getInstallToolEnvWorkflows <- function(tool, containerType) {
  
  data <- allWORKFLOWS
  
  size <- length(data)
  
  intalls <- ""
  
  for (tools in data) {
    splitB <- strsplit(tool, "%")  
    name <- splitB[[1]][1]
    version <- splitB[[1]][2]
    
    if(tools$name == name) {
      if(tools$version == version) {
        if(is.null(tools$env)) {
          return (FALSE)
        } else {
          return(tools$env)
        }
      }
    }
  }
  
  return (FALSE)
}


jlopez's avatar
jlopez committed
217
218