changeset 5:5accedb3133e draft

add search content tool
author mingchen0919
date Mon, 19 Mar 2018 00:43:50 -0400
parents 5ca75e914699
children 4bc7752bfd72
files get_content_types.xml search_contents.Rmd search_contents.xml search_contents_render.R
diffstat 4 files changed, 141 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/get_content_types.xml	Sun Mar 18 23:24:18 2018 -0400
+++ b/get_content_types.xml	Mon Mar 19 00:43:50 2018 -0400
@@ -1,19 +1,11 @@
-<tool id="tool_1" name="Get content types" version="1.0.0">
-    <description>Tripal database explorer: get content types&#xD;
+<tool id="get_content_types" name="Get content types" version="1.0.0">
+  <description>Tripal database explorer: get content types&#xD;
     </description>
-    <requirements>
-        <requirement type="package" version="1.15.0.6-0">pandoc</requirement>
-        <requirement type="package" version="1.20.0">r-getopt</requirement>
-        <requirement type="package" version="1.6">r-rmarkdown</requirement>
-        <requirement type="package" version="1.5">r-jsonlite</requirement>
-        <requirement type="package" version="0.2">r-dt</requirement>
-        <requirement type="package" version="3.1">r-curl</requirement>
-    </requirements>
-    <stdio>
-        <regex match="XXX" source="stderr" level="warning"
-               description="Check the warnings_and_errors.txt file for more details."/>
-    </stdio>
-    <command><![CDATA[export TOOL_DIR='${__tool_directory__}' &&
+  <requirements>
+        <requirement type="package" version="1.15.0.6-0">pandoc</requirement><requirement type="package" version="1.20.0">r-getopt</requirement><requirement type="package" version="1.6">r-rmarkdown</requirement><requirement type="package" version="1.5">r-jsonlite</requirement><requirement type="package" version="0.2">r-dt</requirement><requirement type="package" version="3.1">r-curl</requirement></requirements>
+  <stdio>
+        <regex match="XXX" source="stderr" level="warning" description="Check the warnings_and_errors.txt file for more details."/></stdio>
+  <command><![CDATA[export TOOL_DIR='${__tool_directory__}' &&
 
 Rscript '${__tool_directory__}/'get_content_types_render.R
 
@@ -22,15 +14,11 @@
 	-s '$sink_message'
 	-u '$web_services_root_url'
 ]]></command>
-    <inputs>
-        <param type="text" name="web_services_root_url" label="Web services root URL" optional="False"/>
-    </inputs>
-    <outputs>
-        <data name="report" format="html" label="${tool.name} report" hidden="false"/>
-        <data name="sink_message" format="txt" label="${tool.name} log" from_work_dir="warnings_and_errors.txt"
-              hidden="false"/>
-    </outputs>
-    <citations>
+  <inputs>
+        <param type="text" name="web_services_root_url" label="Web services root URL" optional="False"/></inputs>
+  <outputs>
+        <data name="report" format="html" label="${tool.name} report" hidden="false"/><data name="sink_message" format="txt" label="${tool.name} log" from_work_dir="warnings_and_errors.txt" hidden="false"/></outputs>
+  <citations>
         <citation type="bibtex"><![CDATA[
             @article{allaire2016rmarkdown,
             title={rmarkdown: Dynamic Documents for R, 2016},
@@ -40,8 +28,7 @@
             volume={6},
             year={2016}
             }
-        ]]></citation>
-        <citation type="bibtex"><![CDATA[
+        ]]></citation><citation type="bibtex"><![CDATA[
             @book{xie2015dynamic,
             title={Dynamic Documents with R and knitr},
             author={Xie, Yihui},
@@ -49,6 +36,5 @@
             year={2015},
             publisher={CRC Press}
             }
-        ]]></citation>
-    </citations>
+        ]]></citation></citations>
 </tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/search_contents.Rmd	Mon Mar 19 00:43:50 2018 -0400
@@ -0,0 +1,30 @@
+---
+title: 'HTML report title'
+output:
+    html_document:
+      number_sections: true
+      toc: true
+      theme: cosmo
+      highlight: tango
+      code_folding: hide
+---
+
+```{r setup, include=FALSE, warning=FALSE, message=FALSE}
+knitr::opts_chunk$set(
+  echo = TRUE,
+  error = TRUE
+)
+```
+
+
+# Code for computational analysis
+
+```{r 'step 1'}
+
+```
+
+```{r 'ste[ 2'}
+
+```
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/search_contents.xml	Mon Mar 19 00:43:50 2018 -0400
@@ -0,0 +1,46 @@
+<tool id="search_contents" name="Search contents" version="1.0.0">
+  <description>
+        some description
+    </description>
+  <requirements>
+        <requirement type="package" version="1.15.0.6-0">pandoc</requirement><requirement type="package" version="1.20.0">r-getopt</requirement><requirement type="package" version="1.6">r-rmarkdown</requirement><requirement type="package" version="1.5">r-jsonlite</requirement><requirement type="package" version="0.2">r-dt</requirement><requirement type="package" version="3.1">r-curl</requirement></requirements>
+  <stdio>
+        <regex match="XXX" source="stderr" level="warning" description="Check the warnings_and_errors.txt file for more details."/></stdio>
+  <command><![CDATA[
+        export TOOL_DIRECTORY='${__tool_directory__}' &&
+
+        Rscript '${__tool_directory__}/rmarkdown_report_render.R'
+
+			-e $echo
+			-o $report
+			-d $report.files_path
+			-s $sink_message
+			-t '${__tool_directory__}'
+
+
+        
+    ]]></command>
+  <inputs>
+        <param type="text" name="web_services_root_url" label="Web services root URL" optional="False"/><section name="search_fields" title="Fields being searched" expanded="True"><repeat name="search_field_repeat" title="search fields" min="1" max="20" default="1"><param type="text" name="field_path_search" optional="False"/></repeat></section><section name="extract_fields" title="Fields being extracted"><repeat name="extract_field_repeat" title="Fields being extracted" min="1" max="20" default="1"><param type="text" name="field_path_extract" optional="False"/></repeat></section></inputs>
+  <outputs>
+        <data name="report" format="html" label="${tool.name} report" hidden="false"/><data format="txt" name="sink_message" label="Warnings and Errors" from_work_dir="warnings_and_errors.txt"/></outputs>
+  <citations>
+        <citation type="bibtex"><![CDATA[
+            @article{allaire2016rmarkdown,
+            title={rmarkdown: Dynamic Documents for R, 2016},
+            author={Allaire, J and Cheng, Joe and Xie, Yihui and McPherson, Jonathan and Chang, Winston and Allen, Jeff
+            and Wickham, Hadley and Atkins, Aron and Hyndman, Rob},
+            journal={R package version 0.9},
+            volume={6},
+            year={2016}
+            }
+        ]]></citation><citation type="bibtex"><![CDATA[
+            @book{xie2015dynamic,
+            title={Dynamic Documents with R and knitr},
+            author={Xie, Yihui},
+            volume={29},
+            year={2015},
+            publisher={CRC Press}
+            }
+        ]]></citation></citations>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/search_contents_render.R	Mon Mar 19 00:43:50 2018 -0400
@@ -0,0 +1,51 @@
+##============ Sink warnings and errors to a file ==============
+## use the sink() function to wrap all code within it.
+##==============================================================
+zz = file('warnings_and_errors.txt')
+sink(zz)
+sink(zz, type = 'message')
+
+#------------import libraries--------------------
+options(stringsAsFactors = FALSE)
+
+library(getopt)
+library(rmarkdown)
+#------------------------------------------------
+
+
+#------------get arguments into R--------------------
+# load helper function
+source(paste0(Sys.getenv('TOOL_DIR'), '/helper.R'))
+# import getopt specification matrix from a csv file
+spec_csv = paste0(Sys.getenv('TOOL_DIR'), '/getopt_specification.csv')
+opt = getopt(getopt_specification_matrix(spec_csv))
+opt$X_t = Sys.getenv('TOOL_DIR')
+#----------------------------------------------------
+
+
+#-----------using passed arguments in R 
+#           to define system environment variables---
+do.call(Sys.setenv, opt[-1])
+#----------------------------------------------------
+
+#---------- often used variables ----------------
+# OUTPUT_DIR: path to the output associated directory, which stores all outputs
+# TOOL_DIR: path to the tool installation directory
+OUTPUT_DIR = opt$X_d
+TOOL_DIR =   opt$X_t
+OUTPUT_REPORT = opt$X_o
+RMD_NAME = ''
+
+# create the output associated directory to store all outputs
+dir.create(OUTPUT_DIR, recursive = TRUE)
+
+#-----------------render Rmd--------------
+render(paste0(TOOL_DIR, '/', RMD_NAME), output_file = OUTPUT_REPORT)
+#------------------------------------------
+
+#==============the end==============
+
+
+##--------end of code rendering .Rmd templates----------------
+sink()
+##=========== End of sinking output=============================
\ No newline at end of file