helper_functions.R 4.46 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
getInstallToolPackageWorkflow <- function(tool, containerType) {
  
  data <- allWORKFLOWS
  
  size <- length(data)
  
  intalls <- ""
  res <- ""
  
  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)
          print(tt)
          res <- paste0(res, getInstallToolPackageBioContainer(tt, containerType))
          res <- paste0(res, "\n")
        }
        res <- paste0(res, "\t", tools$install, collapse='\n' )
        return(res)
      }
    }
  }
  
  return("\t")
  
}

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

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

  return("\t")

jlopez's avatar
jlopez committed
161
162
}

jlopez's avatar
jlopez committed
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
189
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
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
217
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
218
219