Mercurial > repos > mingchen0919 > split_multifasta
comparison helper.R @ 0:efd5c022b54d draft
planemo upload
| author | mingchen0919 |
|---|---|
| date | Mon, 09 Apr 2018 12:27:49 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:efd5c022b54d |
|---|---|
| 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. | |
| 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), | |
| 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) | |
| 28 } |
