2
|
1 #' \code{getopt_specification_matrix} returns a getopt specification matrix.
|
|
2 #'
|
|
3 #' @param specification_file a cvs file within the \code{galaxy_tool_directory} which stores getopt specification matrix data.
|
|
4 #' The first column are short flags, the second column are argument masks, the third column
|
|
5 #' is data types. The fourth column are variable names used in the tool XML. These three columns are required.
|
|
6 #' @param gtg_name the name of a running GTG.
|
4
|
7 getopt_specification_matrix = function(specification_file, gtg_name = 'gtg', tool_dir = Sys.getenv('TOOL_DIR')) {
|
|
8 df = read.csv(paste0(tool_dir, '/', specification_file),
|
2
|
9 header = TRUE, stringsAsFactors = FALSE)
|
|
10 # check if there are duplicated short flags
|
|
11 short_flags = df[, 1]
|
|
12 if (length(unique(short_flags)) < length(short_flags)) {
|
|
13 cat('----Duplicated short flags found ----\n')
|
|
14 cat('short flags: ', df[, 1][duplicated(df[, 1])], '\n')
|
|
15 stop('Duplicated short flags are not allowed.')
|
|
16 }
|
|
17
|
|
18 # use short flags to generate long flags
|
|
19 long_flags = paste0('X_', df[, 1])
|
|
20
|
|
21 # specification matrix
|
|
22 df2 = data.frame(long_flags = long_flags,
|
|
23 short_flags = df[, 1],
|
|
24 argument_mask = df[, 2],
|
|
25 data_type = df[, 3])
|
|
26
|
|
27 as.matrix(df2)
|
4
|
28 }
|
|
29
|
|
30
|
|
31
|
|
32 #' \code{file_tree} generate file tree of a directory in the format of HTML lists.
|
|
33 #'
|
|
34 #' @param dir the path to the directory for generating the file tree.
|
|
35 #' @param output_dir the REPORT_FILES_PATH folder name, which has the name style: dataset_NUMBER_files.
|
|
36 # define a recursive function to build html string of the file tree
|
|
37 file_tree = function(dir = '.'){
|
|
38 # get the OUTPUT_DIR folder data: dataset_NUMBER_files
|
|
39 report_files_path = Sys.getenv('REPORT_FILES_PATH')
|
|
40 output_dir = tail(strsplit(report_files_path, '/')[[1]], 1)
|
|
41
|
|
42 files = list.files(path = dir, recursive = FALSE, full.names = TRUE)
|
|
43 # files also include directorys, need to remove directorys
|
|
44 files = files[!dir.exists(files)]
|
|
45 dirs = list.dirs(path = dir, recursive = FALSE, full.names = TRUE)
|
|
46 # hide vakata-jstree-3.3.5 folder
|
|
47 #jstree_index = grep(pattern = 'vakata-jstree-3.3.5', x = dirs)
|
|
48 #dirs = dirs[-jstree_index]
|
|
49 tags$ul(
|
|
50 {
|
|
51 if (length(files) > 0) {
|
|
52 lapply(files, function(x){
|
|
53 path_end = tail(strsplit(x, '/')[[1]],1)
|
|
54 href_path = strsplit(x, paste0(output_dir, '/'))[[1]][2]
|
|
55 li_item = tags$li(tags$a(path_end, href=href_path))
|
|
56 li_item$attribs = list('data-jstree'='{"icon":"jstree-file"}')
|
|
57 li_item
|
|
58 })
|
|
59 }
|
|
60 },
|
|
61 {
|
|
62 if (length(dirs) > 0) {
|
|
63 lapply(dirs, function(x){
|
|
64 x_path = strsplit(x, paste0(output_dir, '/'))[[1]][2]
|
|
65 li_item = tags$li(x_path, file_tree(x))
|
|
66 li_item$attribs = list('data-jstree'='{"icon":"jstree-folder"}')
|
|
67 li_item
|
|
68 })
|
|
69 }
|
|
70 }
|
|
71 )
|
|
72 }
|