X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=using_make_for_science.Rnw;h=2fee8e94ee34bcf3f56847ca8f9112ef4054a53d;hb=a58898c9eb5ffe7aad59a60ea46ee121154440dd;hp=8ff99d10871fb6470e71e3d43a677c3f6518bc0e;hpb=965452df6fbe769c2733543b8880db096a1fb850;p=using_make_for_science.git diff --git a/using_make_for_science.Rnw b/using_make_for_science.Rnw index 8ff99d1..2fee8e9 100644 --- a/using_make_for_science.Rnw +++ b/using_make_for_science.Rnw @@ -77,7 +77,7 @@ \setbeamercolor*{fine separation line}{} \setbeamercovered{transparent} \logo{\begin{tikzpicture}% Pale figure - {\node[opacity=0.7]{\IfFileExists{./logo.pdf}{\includegraphics[height=1.5cm]{logo.pdf}}{}% + {\node[opacity=0.7]{\IfFileExists{./logo.pdf}{\includegraphics[height=1cm,width=1cm,keepaspectratio]{logo.pdf}}{}% };}% \end{tikzpicture}} } @@ -89,6 +89,8 @@ \subject{make for science} \begin{document} +\IfFileExists{./relevant_xkcd.png}{\frame[plain]{\centering \includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{./relevant_xkcd.png}}} + \frame[plain]{\titlepage} \mode
{\maketitle} @@ -145,12 +147,12 @@ \begin{itemize} \item Ubiquitous -- any machine which you can run command line tools on has GNU make available. - \item Large community -- lots of people use GNU make. It's well - understood and you can get questions answered + \item Large community -- lots of people use GNU make. It's not going + to go away tomorrow. \item Simple rules -- all of the rules are in a simple text file which is easily edited and version controlled \item Reasonable debugging -- you can see the commands that make is - going to run fairly easily: \mintinline{shell}{make -n tgt;} + going to run fairly easily: \mintinline{shell}{make -n target;} \item Parallel -- make can make targets in parallel: \mintinline{shell}{make -j8 all;} \item Language agnostic -- make doesn't care what language your code @@ -198,9 +200,9 @@ TARGETS: PREREQUISITES value is assigned at the moment the variable is created \end{itemize} \item Variables can come from the environment and can be overridden on - the command line: \mintinline{shell}{make FOO=bleargh} or - \mintinline{shell}{FOO=blah make}. -\item \mintinline{make}{$@} -- tgt name %$ + the command line: \mintinline{shell}{FOO=blah make} or + \mintinline{shell}{make FOO=bleargh}. +\item \mintinline{make}{$@} -- target name %$ \item \mintinline{make}{$*} -- current stem %$ \item \mintinline{make}{$^} -- all prerequisites %$ \item \mintinline{make}{$<} -- first prerequisite %$ @@ -212,7 +214,7 @@ TARGETS: PREREQUISITES \begin{frame}[fragile]{Some Functions} \begin{itemize} - \item \mintinline{make}{$(patsubst %.bam,%.sam,foo.sam bar.sam)} %$ + \item \mintinline{make}{$(patsubst %.sam,%.bam,foo.sam bar.sam)} %$ -- returns foo.bam bar.bam. \item \mintinline{make}{$(filter-out %.bam,foo.sam bar.bam)} %$ -- returns foo.sam @@ -230,17 +232,17 @@ TARGETS: PREREQUISITES \begin{frame}[fragile]{How does make know what to build?} \begin{minted}[showtabs]{make} -first_tgt: +first_target: touch $@ -second_tgt: first_tgt +second_target: first_target touch $@ \end{minted} \begin{itemize} - \item By default, make builds the first tgt. - \item You can specify a specific tgt to build on the command line - (\mintinline{shell}{make first_tgt}). - \item You can change the default tgt by using the variable - \mintinline{make}{.DEFAULT_GOAL := second_tgt} + \item By default, make builds the first target. + \item You can specify a specific target to build on the command line + (\mintinline{shell}{make first_target}). + \item You can change the default target by using the variable + \mintinline{make}{.DEFAULT_GOAL := second_target} \end{itemize} \end{frame} @@ -252,12 +254,12 @@ second_tgt: first_tgt .PHONY: clean clean: - rm -f first_tgt second_tgt + rm -f first_target second_target \end{minted} \begin{itemize} \item \mintinline{make}{.PHONY} -- any time make considers this - tgt, it is run unconditionally, even if a file exists. - \item \mintinline{make}{.ONESHELL} -- when a tgt is built, all + target, it is run unconditionally, even if a file exists. + \item \mintinline{make}{.ONESHELL} -- when a target is built, all lines will be given to a single invocation of the shell. \item Lots of other special targets which are not described here. \end{itemize} @@ -269,7 +271,7 @@ clean: \begin{frame}[fragile]{Special Targets} \begin{minted}[showtabs]{make} -%.fasta.gz: %.fasta +%.fasta: %.fasta.gz gzip -dc $< > $@ %.bam: %.sam @@ -288,9 +290,12 @@ clean: \subsection{This Presentation} \begin{frame}[fragile]{How this presentation is made} -\inputminted[showtabs]{make}{Makefile} +\inputminted[showtabs,breaklines,firstline=3]{make}{Makefile} +\end{frame} +\begin{frame}[fragile]{How this presentation is made} \begin{itemize} - \item all is the default tgt + \item all is the default + \item Download the optional relevant\_xkcd.png \item Make .tex files from the knitr source. \item The third rule uses latexmk to build the pdf using \XeLaTeX. \end{itemize} @@ -335,7 +340,17 @@ FASTQ_FILES:=$(patsubst %,%_1.fastq.gz,$(SRRS)) $(patsubst %,%_2.fastq.gz,$(SRR endif make_fastq: $(FASTQ_FILES) +\end{minted} +%$ +\begin{itemize} +\item Use ifeq/else/endif to handle paired reads differently from + unpaired reads +\item FASTQ\_FILES is the full set of fastq files dumped from the SRAs. +\end{itemize} +\end{frame} +\begin{frame}[fragile]{Calling records from SRA: Dumping fastq #2} +\begin{minted}[showtabs,breaklines]{make} ifeq ($(NREADS),1) $(FASTQ_FILES): %.fastq.gz: %.sra else @@ -346,8 +361,8 @@ endif \end{minted} %$ \begin{itemize} - \item Call fastq-dump to dump the fastq files \item Handles NREADS of 1 and 2 differently + \item Call fastq-dump to dump the fastq files \end{itemize} \end{frame} @@ -406,6 +421,8 @@ $(SRX)_genes.fpkm_tracking: $(SRX)_star.bam $(BOWTIE_INDEX_DIR)$(GTF) \begin{itemize} \item Timestamps, not MD5sums \item Complicated workflows + \item Interaction of rules can be complicated to understand + \item Yet Another Language \end{itemize} \end{frame} @@ -434,12 +451,17 @@ TARGET: PREREQ1 PREREQ1 \subsection{Complicated Workflows} -\begin{frame}{What about complicated workflows?} +\begin{frame}[fragile]{What about complicated workflows?} \begin{itemize} \item If your workflow is really complicated, what then? \item Use some other language to write your workflow in \item Use a simple makefile which just runs the workflow \end{itemize} + \begin{minted}[showtabs,breaklines]{make} +complicated_workflow_done: req1 req2 req3 + ./complicated_workflow.sh $^; + touch $@; +\end{minted} \end{frame} \section{Further Resources}