|
|
|
@ -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 "<cheRTeX> Detected filename: " $jobname
|
|
|
|
|
echo "<cheRTeX> 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 "<cheRTeX> Detected *.Rnw extension"
|
|
|
|
|
jobfiletype="Rnw"
|
|
|
|
|
else
|
|
|
|
|
# File extension is not *.Rnw
|
|
|
|
|
echo "<cheRTeX> File extension should be *.Rnw"
|
|
|
|
|
# File extension is NOT "[Rr][Nn][Ww]"
|
|
|
|
|
echo "<cheRTeX> This script only handles *.Rnw files"
|
|
|
|
|
echo "<cheRTeX> 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 "<cheRTeX> -----------------------------------------------------------"
|
|
|
|
|
echo "<cheRTeX> sample-matrix: update SHINY, run knit() + markdownToHTML()"
|
|
|
|
|
echo "<cheRTeX> -----------------------------------------------------------"
|
|
|
|
|
|
|
|
|
|
# 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 "<cheRTeX> 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 "<cheRTeX> -----------------------------------------------------------"
|
|
|
|
|
echo "<cheRTeX> sample-matrix: update SHINY, run knit() + markdownToHTML()"
|
|
|
|
|
echo "<cheRTeX> -----------------------------------------------------------"
|
|
|
|
|
|
|
|
|
|
# Old attempts, never worked
|
|
|
|
|
#PORT=$(</home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port)
|
|
|
|
|
#bash -c "R -e 'shiny::runApp(\"/home/taha/chepec/chetex/sample-matrix/shinyapp\", port = $PORT)'"
|
|
|
|
|
# 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')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
# Either no arguments, or more than one argument
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
|