-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (65 loc) · 3.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
##===========================================================================#
## Author: Guido España
## Gather all the data and generate figures & tables automatically
all: data figs manuscript
CURRENT_DIR := $(shell pwd)
##==============================================================================#
## 1. First, collect the data
##==============================================================================#
SRC_DIR = ./analysis/scripts
SRC_FILES := $(SRC_DIR)/run_data_ICER_puerto_rico.R
DATA_OUT := $(SRC_FILES:.R=.Rout)
data: $(DATA_OUT)
$(SRC_DIR)/%.Rout: $(SRC_DIR)/%.R
(cd $(SRC_DIR); R CMD BATCH $(<F))
##==============================================================================#
## 2. Make the figures
##==============================================================================#
FIGS_DIR = ./analysis/figures
FIG_FILES := $(FIGS_DIR)/report_figure_ICER.jpeg \
$(FIGS_DIR)/report_figure_tornado_diagram.jpeg
figs: $(FIG_FILES)
$(FIGS_DIR)/report_figure_ICER.jpeg: $(SRC_DIR)/report_figure_ICER.R $(DATA_OUT)
(cd $(SRC_DIR); R CMD BATCH $(<F))
$(FIGS_DIR)/report_figure_tornado_diagram.jpeg: $(SRC_DIR)/report_figure_tornado_diagram.py $(DATA_OUT)
(cd $(SRC_DIR); python3 $(<F))
##==============================================================================#
## 3. Manuscript
##==============================================================================#
PDF_DIR = ./manuscript
TEX_MASTER := manuscript_latex_demo
PDF_FILES := $(PDF_DIR)/$(TEX_MASTER).pdf
DOC_REF := demo_template.docx
BIB_FILE := Guido_Postdoc_Literature.bib
MASTER_BIB := ~/Dropbox/Literature/Guido_Postdoc_Literature.bib
PANDOC_NUM_DIR := $(CURRENT_DIR)/pandoc
EQ_FILTER := $(PANDOC_NUM_DIR)/pandoc_eqnos_tex.py
TBL_FILTER := $(PANDOC_NUM_DIR)/pandoc_tablenos_tex.py
FIG_FILTER := $(PANDOC_NUM_DIR)/pandoc_fignos_tex.py
BIB_STYLE := ~/Dropbox/Literature/style_files/plos-computational-biology.csl
PANDOC_FLAGS := --filter pandoc-citeproc --csl $(BIB_STYLE) --reference-doc $(DOC_REF) --mathml --bibliography=$(BIB_FILE) --filter $(EQ_FILTER) --filter $(TBL_FILTER) --filter $(FIG_FILTER) -M reference-section-title=References
manuscript: $(PDF_FILES) $(PDF_DIR)/$(TEX_MASTER).docx
$(PDF_DIR)/manuscript_latex_demo.pdf: $(PDF_DIR)/$(TEX_MASTER).tex $(DATA_OUT) $(FIG_FILES) $(PDF_DIR)/table_ICER_psa.tex $(PDF_DIR)/$(BIB_FILE)
(cd $(PDF_DIR); pdflatex $(TEX_MASTER);\
bibtex $(TEX_MASTER); pdflatex $(TEX_MASTER);\
pdflatex $(TEX_MASTER))
$(PDF_DIR)/table_ICER_psa.tex: $(SRC_DIR)/table_ICER_psa.R $(DATA_OUT)
(cd $(SRC_DIR); R CMD BATCH $(<F))
$(PDF_DIR)/$(TEX_MASTER).docx: $(PDF_DIR)/$(TEX_MASTER).tex $(PDF_DIR)/$(TEX_MASTER).pdf
(cd $(PDF_DIR); pandoc $(<F) -o $(@F) $(PANDOC_FLAGS))
## Always copy the master bib file
$(PDF_DIR)/$(BIB_FILE): $(MASTER_BIB)
(cp $(MASTER_BIB) $(PDF_DIR)/$(BIB_FILE))
##==============================================================================#
## Clean stuff
##==============================================================================#
clean:
rm -fv $(DATA_OUT); rm -fv $(FIG_FILES); rm -fv $(PDF_FILES)
cleanData:
rm -fv $(DATA_OUT)
cleanFigs:
rm -fv $(FIG_FILES)
cleanTex:
rm -fv $(PDF_FILES)
cleanJunk:
(cd $(PDF_DIR); rm -fv *.log; rm -fv *.out; rm -fv *.blg; rm -rfv _region_.*; rm -fv *.aux; rm -rfv auto)