From 4ef82b2e13e6f3797a20e87121d9241ea768979f Mon Sep 17 00:00:00 2001 From: "taha@mkem" Date: Wed, 21 May 2014 14:13:52 +0200 Subject: [PATCH] chertex.sh now handles sample-matrix jobs only to produce HTML (Shiny) output. Previously a pdf file was always created as well, but from now on, sample-matrix will be exclusively used in the Shiny app. --- chertex.sh | 64 ++++++++++++++++++++++++--------------------- chrome-with-tabs.sh | 6 +++-- sendfromgmail.py | 27 +++++++++---------- 3 files changed, 51 insertions(+), 46 deletions(-) mode change 100644 => 100755 sendfromgmail.py diff --git a/chertex.sh b/chertex.sh index 56aa16f..3ae34bc 100755 --- a/chertex.sh +++ b/chertex.sh @@ -10,11 +10,11 @@ #################################################### clear -echo "---------------------------------------------------------------" -echo "cheRTeX -- a script for processing R-Sweave-LaTeX-TikZ projects" -echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" -echo "MMX -- taha.ahmed@mkem.uu.se -- CHEPEC doctoral degree project" -echo "---------------------------------------------------------------" +echo "-----------------------------------------------------------------------" +echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects" +echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" +echo "MMXIV -- taha.ahmed@kemi.uu.se -- CHEPEC doctoral degree project" +echo "-----------------------------------------------------------------------" ## If the file .latexmkrc exists in the current directory, ## set the flag ltxmkrc=TRUE @@ -27,16 +27,18 @@ else echo "--- This job did not request LaTeXMK RC file" fi - +# define some commands Rfiletype="R" TeXfiletype="tex" tikzfiles="*.tikz" Rnwfiles="*.Rnw" auxfiles="*.aux *.bbl *.bcf *.blg *.fdb* *.figlist *.fls *.lof *.log *.lot *.lox *.makefile *.map *.out *.run* *.tdo *.toc *.dep *.dpth" + +# depending on number of args and their content, do different things... if [ $# -eq 1 ]; then # Check if the argument contains a filetype - # Assumes a complete filename was passed + # (assumes a complete filename was passed) jobfilename=$1 jobfiletype=${jobfilename#*.} # File extension jobname=${jobfilename%.*} # Filename without extension part @@ -44,14 +46,14 @@ if [ $# -eq 1 ]; then echo " Detected filename: " $jobname echo " Detected extension:" $jobfiletype - # Verifying that the file extension is *.Rnw + # Verify that the file extension is "[Rr][Nn][Ww]" if [[ $jobfiletype == "Rnw" || $jobfiletype == "rnw" || $jobfiletype == "RNW" ]]; then - # File extension is *.Rnw + # File extension is indeed "[Rr][Nn][Ww]" echo " Detected *.Rnw extension" jobfiletype="Rnw" else - # File extension is not *.Rnw - echo " File extension should be *.Rnw" + # File extension is NOT "[Rr][Nn][Ww]" + echo " This script only handles *.Rnw files" echo " Terminating..." exit 1 fi @@ -59,8 +61,27 @@ if [ $# -eq 1 ]; then # Introducing a short delay to enable on-screen reading of previous echo /home/taha/chepec/chetex/common/bash/simpledelay.sh 2 echo "Delay completed" - - ## Handle knitr or pgfSweave jobs separately + + + #### Special treatment for sample-matrix.Rnw + # If $jobname is sample-matrix, run only knitr and markdown, then exit + if [[ $jobname == "sample-matrix" ]]; then + echo " -----------------------------------------------------------" + echo " sample-matrix: update SHINY, run knit() + markdownToHTML()" + echo " -----------------------------------------------------------" + + # Before starting new shiny process, kill any previous instances + pkill -f "shiny::runApp" + bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" & + Rscript -e "library(knitr); knit(input='$jobname.Rmd', output='$jobname.md')" + Rscript -e "library(markdown); markdownToHTML('$jobname.md', '$jobname.html', stylesheet = 'custom.css')" + echo " Terminating..." + /home/taha/chepec/chetex/common/bash/simpledelay.sh 14 + exit 1 + fi + + + ## Handle knitr or pgfSweave jobs (each requires separate treatment) ## But how should we tell the difference between them? ## There is no obvious way to tell the difference (apart from reading the *.Rnw file) ## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme @@ -119,23 +140,6 @@ if [ $# -eq 1 ]; then latexmk -pdf -bibtex $jobname fi - ## THIS IS A QUICK-AND-DIRTY FIX FOR SAMPLE-MATRIX - # If $jobname is sample-matrix, run knitr and markdown - if [[ $jobname == "sample-matrix" ]]; then - echo " -----------------------------------------------------------" - echo " sample-matrix: update SHINY, run knit() + markdownToHTML()" - echo " -----------------------------------------------------------" - - # Old attempts, never worked - #PORT=$(