|
|
@ -10,11 +10,11 @@
|
|
|
|
####################################################
|
|
|
|
####################################################
|
|
|
|
|
|
|
|
|
|
|
|
clear
|
|
|
|
clear
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
echo "-----------------------------------------------------------------------"
|
|
|
|
echo "cheRTeX -- a script for processing R-Sweave-LaTeX-TikZ projects"
|
|
|
|
echo "cheRTeX -- a script for processing R--Sweave/knitr--LaTeX/TikZ projects"
|
|
|
|
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
|
|
|
|
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
|
|
|
|
echo "MMX -- taha.ahmed@mkem.uu.se -- CHEPEC doctoral degree project"
|
|
|
|
echo "MMXIV -- taha.ahmed@kemi.uu.se -- CHEPEC doctoral degree project"
|
|
|
|
echo "---------------------------------------------------------------"
|
|
|
|
echo "-----------------------------------------------------------------------"
|
|
|
|
|
|
|
|
|
|
|
|
## If the file .latexmkrc exists in the current directory,
|
|
|
|
## If the file .latexmkrc exists in the current directory,
|
|
|
|
## set the flag ltxmkrc=TRUE
|
|
|
|
## set the flag ltxmkrc=TRUE
|
|
|
@ -27,16 +27,18 @@ else
|
|
|
|
echo "--- This job did not request LaTeXMK RC file"
|
|
|
|
echo "--- This job did not request LaTeXMK RC file"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# define some commands
|
|
|
|
Rfiletype="R"
|
|
|
|
Rfiletype="R"
|
|
|
|
TeXfiletype="tex"
|
|
|
|
TeXfiletype="tex"
|
|
|
|
tikzfiles="*.tikz"
|
|
|
|
tikzfiles="*.tikz"
|
|
|
|
Rnwfiles="*.Rnw"
|
|
|
|
Rnwfiles="*.Rnw"
|
|
|
|
auxfiles="*.aux *.bbl *.bcf *.blg *.fdb* *.figlist *.fls *.lof *.log *.lot *.lox *.makefile *.map *.out *.run* *.tdo *.toc *.dep *.dpth"
|
|
|
|
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
|
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
# Check if the argument contains a filetype
|
|
|
|
# Check if the argument contains a filetype
|
|
|
|
# Assumes a complete filename was passed
|
|
|
|
# (assumes a complete filename was passed)
|
|
|
|
jobfilename=$1
|
|
|
|
jobfilename=$1
|
|
|
|
jobfiletype=${jobfilename#*.} # File extension
|
|
|
|
jobfiletype=${jobfilename#*.} # File extension
|
|
|
|
jobname=${jobfilename%.*} # Filename without extension part
|
|
|
|
jobname=${jobfilename%.*} # Filename without extension part
|
|
|
@ -44,14 +46,14 @@ if [ $# -eq 1 ]; then
|
|
|
|
echo "<cheRTeX> Detected filename: " $jobname
|
|
|
|
echo "<cheRTeX> Detected filename: " $jobname
|
|
|
|
echo "<cheRTeX> Detected extension:" $jobfiletype
|
|
|
|
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
|
|
|
|
if [[ $jobfiletype == "Rnw" || $jobfiletype == "rnw" || $jobfiletype == "RNW" ]]; then
|
|
|
|
# File extension is *.Rnw
|
|
|
|
# File extension is indeed "[Rr][Nn][Ww]"
|
|
|
|
echo "<cheRTeX> Detected *.Rnw extension"
|
|
|
|
echo "<cheRTeX> Detected *.Rnw extension"
|
|
|
|
jobfiletype="Rnw"
|
|
|
|
jobfiletype="Rnw"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# File extension is not *.Rnw
|
|
|
|
# File extension is NOT "[Rr][Nn][Ww]"
|
|
|
|
echo "<cheRTeX> File extension should be *.Rnw"
|
|
|
|
echo "<cheRTeX> This script only handles *.Rnw files"
|
|
|
|
echo "<cheRTeX> Terminating..."
|
|
|
|
echo "<cheRTeX> Terminating..."
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -59,8 +61,27 @@ if [ $# -eq 1 ]; then
|
|
|
|
# Introducing a short delay to enable on-screen reading of previous echo
|
|
|
|
# Introducing a short delay to enable on-screen reading of previous echo
|
|
|
|
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2
|
|
|
|
/home/taha/chepec/chetex/common/bash/simpledelay.sh 2
|
|
|
|
echo "Delay completed"
|
|
|
|
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?
|
|
|
|
## But how should we tell the difference between them?
|
|
|
|
## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
|
|
|
|
## There is no obvious way to tell the difference (apart from reading the *.Rnw file)
|
|
|
|
## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme
|
|
|
|
## IN ALL KNITR DIRECTORIES, CREATE A FILE NAMED: .knitme
|
|
|
@ -119,23 +140,6 @@ if [ $# -eq 1 ]; then
|
|
|
|
latexmk -pdf -bibtex $jobname
|
|
|
|
latexmk -pdf -bibtex $jobname
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
else
|
|
|
|
# Either no arguments, or more than one argument
|
|
|
|
# Either no arguments, or more than one argument
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|