# HG changeset patch
# User mingchen0919
# Date 1521784404 14400
# Node ID d79569f269c73ca990feb413f4d8b476973a7bc4
planemo upload
diff -r 000000000000 -r d79569f269c7 LICENSE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Staton Laboratory
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff -r 000000000000 -r d79569f269c7 README.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,116 @@
+# Dynamic Galaxy Tool wrappers
+
+Use this repository as a template to develop a dynamic Galaxy tools in one minute!
+
+## Step 1: clone this repository
+
+```bash
+git clone https://github.com/statonlab/dynamic-galaxy-tool-wrappers.git
+```
+
+## Step 2: edit tool requirements
+
+Open the `dynamic_tool_wrappers_macros.xml` file and add your tool requirements. **Only tools from the
+[conda repository](https://anaconda.org/anaconda/repo) can be added as a tool requirement. For example, for a wrapper
+of the **FastQC** tool, go to [https://anaconda.org/anaconda/repo](https://anaconda.org/anaconda/repo) and search for
+`fastqc`. You will get a list of `fastqc` tools. Find the appropriate version and add it as a tool requirement.
+
+Before editing tool requirement:
+
+```xml
+
+ pandoc
+ r-rmarkdown
+
+```
+
+After editing tool requirement:
+
+```xml
+
+ pandoc
+ r-rmarkdown
+ fastqc
+
+```
+
+
+
+## Step 3: edit template for a specific command line tool
+
+Open the `dynamic_tool_wrappers_macros.xml` file and replace `tool_name` in
+`` with a valid command line tool name.
+
+```xml
+
+
+
+
+
+```
+
+Use the **FastQC** tool as an example again, the content after replacement would be
+
+```xml
+
+
+
+
+
+```
+
+You can add multiple `tool_name` options if the tool has sub command line tools. For example,
+for the `samtools` tool, it could be
+
+```xml
+
+
+
+
+
+
+
+```
+
+## Step 4: edit **tool name** and **tool id** in `dynamic_tool.xml`
+
+Open the `dynamic_tool.xml` file and replace `dynamic_tool` with an appropriate **tool id** and the `dynamic tool` with
+an appropriate **tool name**.
+
+```xml
+
+```
+
+Use the **FastQC** tool as an example, it could be:
+
+```xml
+
+```
+
+## Step 5: Publish tool to [ToolShed](https://toolshed.g2.bx.psu.edu/) or [Test ToolShed](https://testtoolshed.g2.bx.psu.edu/)
+
+Please check [planemo's documentation site](http://planemo.readthedocs.io/en/latest/publishing.html) for more details.
+
+* Within the tool directory, `planemo shed_init` command can be used to bootstrap a `.shed.yml` file.
+
+```bash
+planemo shed_init --name=
+ --owner=
+ --description=
+ [--remote_repository_url=]
+ [--homepage_url=]
+ [--long_description=]
+ [--category=]*
+```
+
+* **Create tool repository on ToolShed or Test ToolShed**
+
+```bash
+planemo shed_create --shed_target testtoolshed
+```
+
+* **Update a tool repository**
+
+```bash
+planemo shed_diff --shed_target testtoolshed
+```
\ No newline at end of file
diff -r 000000000000 -r d79569f269c7 dynamic_tool.Rmd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dynamic_tool.Rmd Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,97 @@
+---
+title: 'Dynamic tool'
+output: html_document
+---
+
+```{r setup, include=FALSE, warning=FALSE, message=FALSE}
+knitr::opts_chunk$set(error = TRUE)
+```
+
+## User input
+
+```{r, echo=FALSE}
+##-------- build script files -----------
+
+# build script file: script.sh
+df = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'),
+ sep = '|', header = TRUE)
+
+# get tool name
+tool_name = df[df$type == 'tool_name', 'value']
+# build script for displaying help messages (this probably should be tool specific)
+write(paste0(tool_name, ' -h'),
+ file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/help.sh'))
+
+knitr::kable(df[, c('flag', 'value')])
+
+# if the number of option/argument pairs is larger than 0, build script file
+df2 = df[df$type != 'tool_name', ]
+if (nrow(df2) > 0) {
+ # write tool name as the first line of the script.sh
+ # before running the job, cd into the ${REPORT_FILES_PATH} directory
+ write(paste0(tool_name, ' \\'),
+ paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'))
+ df2 = df[df$type != 'tool_name', ]
+ write(paste(' ', df2$flag, df2$value, '\\', sep = ' '),
+ file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'),
+ append = TRUE )
+ # remember that after writing option/argument lines to the script.sh, the last line
+ # has an extra newline character '\' which causes a problem. We can either remove that extra
+ # '\' or add a new line to the end. We choose to add a new line.
+
+ # add an extra line to the end to redirect stdout to stdout.txt and stderr to stderr.txt
+ write(' > ${REPORT_FILES_PATH}/stdout.txt 2>${REPORT_FILES_PATH}/stderr.txt',
+ paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'), append = TRUE)
+} else {
+ # if no option/argument input, simply display the help message
+ write(paste0(tool_name, ' -h'),
+ file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/script.sh'))
+}
+
+```
+
+
+```{bash, echo=FALSE}
+## code to open help documentation
+sh ${REPORT_FILES_PATH}/help.sh > ${TOOL_HELP_DOC}
+```
+
+```{bash, results='asis', echo=FALSE}
+echo '## Show help documentation'
+echo ''
+echo ''
+echo '```bash'
+cat ${REPORT_FILES_PATH}/help.sh
+echo '```'
+```
+
+
+```{bash, echo=FALSE}
+# run job script
+# it's important to run the job within the REPORT_FILES_PATH
+cd ${REPORT_FILES_PATH} && sh script.sh
+```
+
+```{bash, results='asis', echo=FALSE}
+echo '## Job script'
+echo ''
+echo ''
+echo '```bash'
+cat ${REPORT_FILES_PATH}/script.sh
+echo '```'
+```
+
+
+```{r, results='asis', echo=FALSE}
+cat('##All output files')
+cat('\n\n')
+all_files = list.files(path = Sys.getenv('REPORT_FILES_PATH'),
+ full.names = TRUE,
+ recursive = TRUE)
+
+for (f in sub(Sys.getenv('REPORT_FILES_PATH'), '.', all_files) ) {
+ cat('* [', f, '](', f, ')\n')
+}
+cat('\n')
+```
+
diff -r 000000000000 -r d79569f269c7 dynamic_tool.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dynamic_tool.xml Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,27 @@
+
+
+ dynamic_tool_wrappers_macros.xml
+
+
+
+
+ fastqc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r d79569f269c7 dynamic_tool_render.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dynamic_tool_render.R Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,28 @@
+##============ Sink warnings and errors to a file ==============
+## use the sink() function to wrap all code within it.
+##==============================================================
+zz = file(Sys.getenv('TOOL_LOG'))
+sink(zz)
+sink(zz, type = 'message')
+
+#------------import libraries--------------------
+options(stringsAsFactors = FALSE)
+
+library(getopt)
+library(rmarkdown)
+#------------------------------------------------
+
+#------------------------------------------------
+options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'),
+ sep = '|', header = TRUE)
+
+
+#-----------------render Rmd--------------
+render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/dynamic_tool.Rmd'),
+ output_file = Sys.getenv('REPORT'))
+#------------------------------------------
+
+
+##--------end of code rendering .Rmd templates----------------
+sink()
+##=========== End of sinking output=============================
\ No newline at end of file
diff -r 000000000000 -r d79569f269c7 dynamic_tool_wrappers_macros.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dynamic_tool_wrappers_macros.xml Fri Mar 23 01:53:24 2018 -0400
@@ -0,0 +1,186 @@
+
+
+
+ pandoc
+ r-rmarkdown
+ star
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ options_and_arguments.txt &&
+
+ ############ tool_name
+ ##-t '$tool_name'
+ echo "tool_name|tool_flag|${tool_name}" >> options_and_arguments.txt &&
+
+ ####################################################
+ ## loop through repeats to get option/argument pairs
+ ####################################################
+
+ ############ option_argument_one_dataset
+ #for i in $option_argument_one_dataset_repeat:
+ #set $item = 'one_dataset|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+ ############ option_argument_multiple_datasets
+ #for i in $option_argument_multiple_datasets_repeat:
+ #set $item = 'multiple_datasets|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+ ############ option_argument_path_relative_to_upstream_tool
+ #for i in $option_argument_path_relative_to_upstream_tool_repeat:
+ #set $item = 'path_relative_to_upstream_tool|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+ ############ option_argument_string
+ #for i in $option_argument_string_repeat:
+ #set $item = 'string|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+ ############ option_argument_float
+ #for i in $option_argument_float_repeat:
+ #set $item = 'float|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+
+ ############ option_argument_integer
+ #for i in $option_argument_integer_repeat:
+ #set $item = 'integer|' + str($i.flag) + "|" + str($i.value)
+ echo '$item' >> options_and_arguments.txt &&
+ #end for
+
+
+ ############ output_set
+ ## '$report'
+ ## '$report.files_path'
+ ## '$tool_help_doc'
+ ## '$tool_output_dir'
+ ## '$tool_log'
+ #######################
+ export REPORT='$report' &&
+ export REPORT_FILES_PATH='$report.files_path' &&
+ export TOOL_HELP_DOC='$tool_help_doc' &&
+ export TOOL_OUTPUT_DIR='$tool_output_dir' &&
+ export TOOL_LOG='$tool_log' &&
+
+
+ ############ save tool files path to a tool output so that it can be accessed from galaxy history
+ echo '$report.files_path' > $tool_output_dir &&
+
+ ############ run render R script to render R markdowns
+ Rscript '${__tool_directory__}/dynamic_tool_render.R'
+
+ ]]>
+
+
+
+
+
+
+
+
\ No newline at end of file