From 1462a6c32fb89fec094b9a749457f3145f9eed78 Mon Sep 17 00:00:00 2001 From: Fabian Brand Date: Fri, 15 Dec 2023 14:38:40 +0100 Subject: [PATCH 01/12] feat: Adding slides explaining the setup, usage and creation of snakemake wrappers. This is a first attempt to provide some slides to explain all aspects of wrappers in some depth. Refs: #44 --- slides/Snakemake_HPC_Creators.tex | 2 +- slides/Snakemake_HPC_Users.tex | 5 +- slides/common/wrapper.tex | 140 ++++++++++++++++++++++++++++++ slides/creators/wrapper.tex | 136 +++++++++++++++++++++++++++++ 4 files changed, 281 insertions(+), 2 deletions(-) create mode 100644 slides/common/wrapper.tex create mode 100644 slides/creators/wrapper.tex diff --git a/slides/Snakemake_HPC_Creators.tex b/slides/Snakemake_HPC_Creators.tex index c8b46e7..52a2535 100644 --- a/slides/Snakemake_HPC_Creators.tex +++ b/slides/Snakemake_HPC_Creators.tex @@ -75,7 +75,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \include{common/Workflow_Parameterization_for_HPC} - +\include{creators/wrapper} \end{document} diff --git a/slides/Snakemake_HPC_Users.tex b/slides/Snakemake_HPC_Users.tex index f83d624..728133b 100644 --- a/slides/Snakemake_HPC_Users.tex +++ b/slides/Snakemake_HPC_Users.tex @@ -46,8 +46,11 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \include{common/Reports} - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\include{common/Contributing} % TODO: should include reporting issues + +\include{common/wrapper} + \end{document} diff --git a/slides/common/wrapper.tex b/slides/common/wrapper.tex new file mode 100644 index 0000000..6f7a463 --- /dev/null +++ b/slides/common/wrapper.tex @@ -0,0 +1,140 @@ +\section{Snakemake Wrappers} + +\subsection*{Basics} + +\begin{frame} + \frametitle{Outline} + \begin{columns}[t] + \begin{column}{.5\textwidth} + \tableofcontents[sections={1-9},currentsection] + \end{column} + \begin{column}{.5\textwidth} + \tableofcontents[sections={10-18},currentsection] + \end{column} + \end{columns} +\end{frame} + +\begin{frame} + \frametitle{What is this about?} + \begin{question}[Questions] + \begin{itemize} + \item What is a snakemake Wrapper? + \item How can snakemake wrappers be used to write reproducible workflows? + \end{itemize} + \end{question} + \begin{docs}[Objectives] + \begin{enumerate} + \item Introduce the concept of snakemake wrappers + \item Include snakemake wrappers in your workflows + \item Reproducibility of snakemake wrappers + \end{enumerate} + \end{docs} +\end{frame} + +\begin{frame}{Introduction to Wrappers} + For a single tool, Snakemake Wrappers do: + \begin{itemize}[<+->] + \item Document usage + \item Describe the dependencies + \item Provide a way to call the tool with information from snakemake + \end{itemize} + This setup makes snakemake wrappers reusable across multiple workflows. +\end{frame} + +\begin{frame}{Introduction to Wrappers} + Wrappers consist of three components: + \begin{enumerate} + \item A description of their usage (\altverb{meta.yaml}) + \item A conda environment description of all dependencies of the tool (\altverb{environment.yaml}) + \item A python script that invokes the tool (\altverb{wrapper.py}) + \end{enumerate} + Since they are reusable, there is a large repository online of tried and tested + wrappers written by the community: \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} +\end{frame} + +\begin{frame}[fragile]{Using Wrappers} + Using snakemake wrappers can be achieved easily: + \begin{lstlisting}[language=Python,style=Python] +rule bwa_map: + input: + reads=["input/{sample}_1.fq.gz", "input/{sample}_2.fq.gz"], + idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"), + output: + "output/{sample}.bam" + params: + extra=r"-R '@RG\tID:{sample}\tSM:{sample}'", + sorting="none", # Can be 'none', 'samtools' or 'picard'. + sort_order="queryname", # Can be 'queryname' or 'coordinate'. + sort_extra="", # Extra args for samtools/picard. + threads: 8 + wrapper: + "v3.2.0/bio/bwa/mem" + \end{lstlisting} + \begin{docs} + This example uses the community snakemake-wrappers repository \altverb{bwa-mem} wrapper. + \end{docs} +\end{frame} + +\begin{frame}[fragile]{Using Wrappers: In- and Output} + Input and Output of the rules has to match the definition of the snakemake wrapper. + \begin{lstlisting}[language=Python,style=Python] +rule bwa_map: + input: + reads=["input/{sample}_1.fq.gz", "input/{sample}_2.fq.gz"], + idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"), + output: + "output/{sample}.bam" + ... + \end{lstlisting} + \begin{docs} + The \altverb{bwa-mem} wrapper expects an input object with two attributes + \altverb{reads} and \altverb{idx} and writes to a single output file. + \end{docs} +\end{frame} + +\begin{frame}[fragile]{Using Wrappers: Parameters} + Parameters may be used by wrappers to influence the behaviour, settings or resource usage. + \begin{lstlisting}[language=Python,style=Python] +rule bwa_map: + ... + params: + extra=r"-R '@RG\tID:{sample}\tSM:{sample}'", + sorting="none", # Can be 'none', 'samtools' or 'picard'. + sort_order="queryname", # Can be 'queryname' or 'coordinate'. + sort_extra="", # Extra args for samtools/picard. + threads: 8 + ... + \end{lstlisting} + \begin{docs} + \altverb{bwa-mem} supports custom arguments like \altverb{sort_order} and + the common \altverb{extra} flag, that is used to supply command line parameters + for the invocation of the tool. The \altverb{threads} and \altverb{resources} + settings from a snakemake rule are also commonly used to set memory or parallelization + parameters for each tool. + \end{docs} +\end{frame} + +\begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} + The \altverb{wrapper} directive signals that snakemake should execute this rule with + a wrapper. + \begin{lstlisting}[language=Python,style=Python] +rule bwa_map: + ... + wrapper: + "v3.2.0/bio/bwa/mem" + \end{lstlisting} + \begin{docs} + The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} + flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. + \end{docs} +\end{frame} + +\begin{frame}{Advantages of Wrappers} + Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: + \begin{itemize}[<+->] + \item Code is reusable across workflows and can be shared with others + \item Complex invocations of tools do not clutter your snakemake workflow definitions + \item With versioned wrappers, you workflow is easily reproducible + \item Community wrappers often get you started quickly using a new tool correctly + \end{itemize} +\end{frame} diff --git a/slides/creators/wrapper.tex b/slides/creators/wrapper.tex new file mode 100644 index 0000000..f36153e --- /dev/null +++ b/slides/creators/wrapper.tex @@ -0,0 +1,136 @@ +\input{common/wrapper} + +\subsection*{Advanced} + +\begin{frame}{Creating New Wrappers} + Creating snakemake wrappers is as easy as creating the three constituent parts: + \begin{description}[<+->] + \item[\texttt{meta.yaml}:] A documentation file, containing information about the tool and the wrapper + \item[\texttt{environment.yaml}:] A conda environment to install the tool and its dependencies + \item[\texttt{wrapper.py}:] The python code to run the tool + \end{description} + \only<1>{ + Contents of the documentation: + \begin{itemize} + \item The name of the wrapper and the tool it wraps + \item Links to the tool source code + \item Description of the input and output files that should be supplied by any rule using the wrapper + \item Optionally, some documentation of custom arguments like \altverb{extra} + \item When contributing to the community: Authors of the wrapper + \end{itemize} + } + \only<2>{ + Software Environment: + \begin{itemize} + \item Install all necessary tools and dependencies to run the wrapper code (including python libraries) + \item Preferably tool versions should be fixed, s.t. later usage of the same wrapper results in the same output + \end{itemize} + } + \only<3>{ + The wrapper code: + \begin{itemize} + \item Translate the snakemake rule parameters into a valid invocation of the tool + \item Apply necessary pre- and postprocessing steps to guarantee valid output + \end{itemize} + } + \only<4>{ + \begin{docs} + Wrappers can be improved by providing \altverb{Unit Tests} that can validate the wrapper code + and tool versions with known output. + \end{docs} + } +\end{frame} + +\begin{frame}[fragile]{Creating New Wrappers: Python Code} + \altverb{wrapper.py} is the core component of any wrapper as it takes care of running the actual + program. + \begin{onlyenv}<2> + \begin{lstlisting}[language=Python,style=Python,gobble=12] + # Core setup of a `wrapper.py` script + # 1. Python Imports + import tempfile + import os + from snakemake.shell import shell + \end{lstlisting} + \end{onlyenv} + \begin{onlyenv}<3> + \begin{lstlisting}[language=Python,style=Python,gobble=12] + # Core setup of a `wrapper.py` script + # 2. Fetch the snakemake input and output parameter + extra = snakemake.params.get("extra", "") + \end{lstlisting} + The snakemake object has the attributes \altverb{input}, \altverb{output} and \altverb{params} + containing the respective rule parameter. + \end{onlyenv} + \begin{onlyenv}<4> + \begin{lstlisting}[language=Python,style=Python,gobble=12] + # Core setup of a `wrapper.py` script + Default value + @vvvv@ + extra = snakemake.params.get("extra", "") + @^^^^^^^@ + Name of the parameter + \end{lstlisting} + The snakemake object has the attributes \altverb{input}, \altverb{output} and \altverb{params} + containing the respective rule parameter. + \end{onlyenv} + \begin{onlyenv}<5> + \begin{lstlisting}[language=Python,style=Python,gobble=12] + # Core setup of a `wrapper.py` script + extra = snakemake.params.get("extra", "") + reads = snakemake.input.get("reads", []) + output = snakemake.output[0] + \end{lstlisting} + \begin{itemize} + \item These values can also be addressed as arrays + \item The wrapper must take care of checking for errors in the input and raise Exceptions if necessary + \end{itemize} + \end{onlyenv} + \begin{hint} + The \altverb{snakemake} object provides access to snakemake variables from inside the + wrapper script. + \end{hint} +\end{frame} + +\begin{frame}[fragile]{Creating New Wrappers: Helper Functions} + Snakemake provides several helper functions that make it easier to code wrappers. + \begin{lstlisting}[language=Python,style=Python,gobble=8] + # Snakemake Helper Functions + + # Run a specific tool on the command line. + snakemake.shell("/bin/true") + + # Format the log statement of the current rule, s.t. it can be applied to a shell command. + snakemake.log_fmt_shell(stdout=True, stderr=True, append=False) + + # Define the executable used to launch your shell commands. + snakemake.shell.executable("/bin/bash") + \end{lstlisting} +\end{frame} + +\begin{frame}{Assembling the new Wrapper} + With these ingredients, you can write wrappers for your own tools. + Recap of the steps required to create a new wrapper: + \begin{itemize} + \item Pick the tool and write the wrapper + \item Test the wrapper and document how to use it + \item Optionally, write some unit testing code for the wrapper + \item Use it in your workflows + \end{itemize} + \begin{docs} + If you write new wrappers, please contribute them to the community effort. + \end{docs} +\end{frame} + +\begin{frame}{Contributing Wrappers to the Community} + New wrappers are always welcome at \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers}. + In order to contribute a new wrapper, please provide: + \begin{itemize} + \item A Wrapper, including \altverb{meta.yaml}, \altverb{environment.yaml} and \altverb{wrapper.py} + \item A simple unit test with some example data + \end{itemize} + \begin{hint} + Your example serves as the main documentation for the wrapper, so make sure to document + the usage of any custom parameters, input and output variables. + \end{hint} +\end{frame} From 07909c0b7ed75c03149a89433a4a867ea4a0dead Mon Sep 17 00:00:00 2001 From: meesters Date: Wed, 31 Jan 2024 15:24:02 +0100 Subject: [PATCH 02/12] common/wrapper - inserted optical frame separators --- slides/common/wrapper.tex | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/slides/common/wrapper.tex b/slides/common/wrapper.tex index 6f7a463..515ce63 100644 --- a/slides/common/wrapper.tex +++ b/slides/common/wrapper.tex @@ -1,7 +1,10 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Snakemake Wrappers} -\subsection*{Basics} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Basics} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Outline} \begin{columns}[t] @@ -14,6 +17,7 @@ \subsection*{Basics} \end{columns} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{What is this about?} \begin{question}[Questions] @@ -31,6 +35,7 @@ \subsection*{Basics} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Introduction to Wrappers} For a single tool, Snakemake Wrappers do: \begin{itemize}[<+->] @@ -41,6 +46,7 @@ \subsection*{Basics} This setup makes snakemake wrappers reusable across multiple workflows. \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Introduction to Wrappers} Wrappers consist of three components: \begin{enumerate} @@ -52,6 +58,7 @@ \subsection*{Basics} wrappers written by the community: \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers} Using snakemake wrappers can be achieved easily: \begin{lstlisting}[language=Python,style=Python] @@ -75,6 +82,7 @@ \subsection*{Basics} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers: In- and Output} Input and Output of the rules has to match the definition of the snakemake wrapper. \begin{lstlisting}[language=Python,style=Python] @@ -92,6 +100,7 @@ \subsection*{Basics} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers: Parameters} Parameters may be used by wrappers to influence the behaviour, settings or resource usage. \begin{lstlisting}[language=Python,style=Python] @@ -114,6 +123,7 @@ \subsection*{Basics} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} The \altverb{wrapper} directive signals that snakemake should execute this rule with a wrapper. @@ -129,6 +139,7 @@ \subsection*{Basics} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Advantages of Wrappers} Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: \begin{itemize}[<+->] From 2cf4d628095c50265ff2169b335167ee6b7977da Mon Sep 17 00:00:00 2001 From: meesters Date: Wed, 31 Jan 2024 15:24:45 +0100 Subject: [PATCH 03/12] moved common/wrapper.tex -> common/using_wrappers.tex --- slides/common/{wrapper.tex => using_wrappers.tex} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename slides/common/{wrapper.tex => using_wrappers.tex} (100%) diff --git a/slides/common/wrapper.tex b/slides/common/using_wrappers.tex similarity index 100% rename from slides/common/wrapper.tex rename to slides/common/using_wrappers.tex From 6a03db313a8dcdb60c56332cd451272eb3b602e1 Mon Sep 17 00:00:00 2001 From: meesters Date: Wed, 31 Jan 2024 15:36:41 +0100 Subject: [PATCH 04/12] Snakemake_HPC_Creators - reflecting name change --- slides/Snakemake_HPC_Creators.tex | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/slides/Snakemake_HPC_Creators.tex b/slides/Snakemake_HPC_Creators.tex index ea99c22..2535c6e 100644 --- a/slides/Snakemake_HPC_Creators.tex +++ b/slides/Snakemake_HPC_Creators.tex @@ -72,12 +72,10 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\include{creators/Uploading_Workflows} - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \include{common/Workflow_Parameterization_for_HPC} -\include{creators/wrapper} - +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\include{creators/using_wrapper} \end{document} From a0fa9d72aaecd3eca2d8853100d8acbec147db32 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 14:51:54 +0100 Subject: [PATCH 05/12] adapted sections and disentagled tex files for wrappers --- slides/Snakemake_HPC_Creators.tex | 3 +- slides/common/HPC_101.tex | 4 +- slides/common/Plotting_DAGs.tex | 4 +- slides/common/Reports.tex | 4 +- slides/common/Why_Workflows.tex | 4 +- .../Workflow_Parameterization_for_HPC.tex | 4 +- slides/common/software_environment.tex | 4 +- slides/common/using_wrappers.tex | 60 +++++++++---------- slides/creators/A_First_Workflow.tex | 4 +- slides/creators/Decorating_the_Workflow.tex | 4 +- slides/creators/Finishing_and_Execution.tex | 4 +- slides/creators/Getting_Started.tex | 4 +- slides/creators/Python_in_Snakemake.tex | 4 +- slides/creators/Sample_Data.tex | 4 +- .../{wrapper.tex => coding_wrappers.tex} | 6 +- 15 files changed, 59 insertions(+), 58 deletions(-) rename slides/creators/{wrapper.tex => coding_wrappers.tex} (98%) diff --git a/slides/Snakemake_HPC_Creators.tex b/slides/Snakemake_HPC_Creators.tex index 2535c6e..a33f5a3 100644 --- a/slides/Snakemake_HPC_Creators.tex +++ b/slides/Snakemake_HPC_Creators.tex @@ -76,6 +76,7 @@ \include{common/Workflow_Parameterization_for_HPC} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\include{creators/using_wrapper} +\include{common/using_wrappers} +\include{creators/coding_wrappers} \end{document} diff --git a/slides/common/HPC_101.tex b/slides/common/HPC_101.tex index e39acb0..ffd0665 100644 --- a/slides/common/HPC_101.tex +++ b/slides/common/HPC_101.tex @@ -6,10 +6,10 @@ \section{How does Clustercomputing work?} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/Plotting_DAGs.tex b/slides/common/Plotting_DAGs.tex index 7cb3d17..8a829ac 100644 --- a/slides/common/Plotting_DAGs.tex +++ b/slides/common/Plotting_DAGs.tex @@ -6,10 +6,10 @@ \section{Plotting DAGs} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/Reports.tex b/slides/common/Reports.tex index 75cf110..23fff78 100644 --- a/slides/common/Reports.tex +++ b/slides/common/Reports.tex @@ -6,10 +6,10 @@ \section{Evaluating Reports} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/Why_Workflows.tex b/slides/common/Why_Workflows.tex index 91367bd..3749f84 100644 --- a/slides/common/Why_Workflows.tex +++ b/slides/common/Why_Workflows.tex @@ -6,10 +6,10 @@ \section{Why Workflows} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/Workflow_Parameterization_for_HPC.tex b/slides/common/Workflow_Parameterization_for_HPC.tex index a06a2fe..7aa05e9 100644 --- a/slides/common/Workflow_Parameterization_for_HPC.tex +++ b/slides/common/Workflow_Parameterization_for_HPC.tex @@ -6,10 +6,10 @@ \section{Parametizing your Workflow - II} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/software_environment.tex b/slides/common/software_environment.tex index cf24705..fbfaa30 100644 --- a/slides/common/software_environment.tex +++ b/slides/common/software_environment.tex @@ -6,10 +6,10 @@ \section{Software Environment} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/common/using_wrappers.tex b/slides/common/using_wrappers.tex index 515ce63..495c433 100644 --- a/slides/common/using_wrappers.tex +++ b/slides/common/using_wrappers.tex @@ -1,22 +1,22 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Snakemake Wrappers} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Basics} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\subsection{Basics} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{What is this about?} @@ -124,28 +124,28 @@ \subsection{Basics} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} - The \altverb{wrapper} directive signals that snakemake should execute this rule with - a wrapper. - \begin{lstlisting}[language=Python,style=Python] -rule bwa_map: - ... - wrapper: - "v3.2.0/bio/bwa/mem" - \end{lstlisting} - \begin{docs} - The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} - flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. - \end{docs} -\end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{frame}{Advantages of Wrappers} - Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: - \begin{itemize}[<+->] - \item Code is reusable across workflows and can be shared with others - \item Complex invocations of tools do not clutter your snakemake workflow definitions - \item With versioned wrappers, you workflow is easily reproducible - \item Community wrappers often get you started quickly using a new tool correctly - \end{itemize} -\end{frame} +% \begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} +% The \altverb{wrapper} directive signals that snakemake should execute this rule with +% a wrapper. +% \begin{lstlisting}[language=Python,style=Python] +% rule bwa_map: +% ... +% wrapper: +% "v3.2.0/bio/bwa/mem" +% \end{lstlisting} +% \begin{docs} +% The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} +% flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. +% \end{docs} +% \end{frame} +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \begin{frame}{Advantages of Wrappers} +% Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: +% \begin{itemize}[<+->] +% \item Code is reusable across workflows and can be shared with others +% \item Complex invocations of tools do not clutter your snakemake workflow definitions +% \item With versioned wrappers, you workflow is easily reproducible +% \item Community wrappers often get you started quickly using a new tool correctly +% \end{itemize} +% \end{frame} diff --git a/slides/creators/A_First_Workflow.tex b/slides/creators/A_First_Workflow.tex index fddec47..a61bb7e 100644 --- a/slides/creators/A_First_Workflow.tex +++ b/slides/creators/A_First_Workflow.tex @@ -6,10 +6,10 @@ \section{A first Workflow} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/Decorating_the_Workflow.tex b/slides/creators/Decorating_the_Workflow.tex index 6482583..7cb83b0 100644 --- a/slides/creators/Decorating_the_Workflow.tex +++ b/slides/creators/Decorating_the_Workflow.tex @@ -6,10 +6,10 @@ \section{Decorating Workflows - Parameterization} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/Finishing_and_Execution.tex b/slides/creators/Finishing_and_Execution.tex index c8dfcbd..ed9a459 100644 --- a/slides/creators/Finishing_and_Execution.tex +++ b/slides/creators/Finishing_and_Execution.tex @@ -6,10 +6,10 @@ \section{Finishing and Executing the Workflow} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/Getting_Started.tex b/slides/creators/Getting_Started.tex index 4deb512..9455286 100644 --- a/slides/creators/Getting_Started.tex +++ b/slides/creators/Getting_Started.tex @@ -6,10 +6,10 @@ \section{Getting Started with Snakemake} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/Python_in_Snakemake.tex b/slides/creators/Python_in_Snakemake.tex index 660a9d6..afe1a59 100644 --- a/slides/creators/Python_in_Snakemake.tex +++ b/slides/creators/Python_in_Snakemake.tex @@ -6,10 +6,10 @@ \section{Snakefiles as Python-Code} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/Sample_Data.tex b/slides/creators/Sample_Data.tex index af1a325..a943d10 100644 --- a/slides/creators/Sample_Data.tex +++ b/slides/creators/Sample_Data.tex @@ -6,10 +6,10 @@ \section{Getting your Sample Data} \frametitle{Outline} \begin{columns}[t] \begin{column}{.5\textwidth} - \tableofcontents[sections={1-9},currentsection] + \tableofcontents[sections={1-7},currentsection] \end{column} \begin{column}{.5\textwidth} - \tableofcontents[sections={10-18},currentsection] + \tableofcontents[sections={8-15},currentsection] \end{column} \end{columns} \end{frame} diff --git a/slides/creators/wrapper.tex b/slides/creators/coding_wrappers.tex similarity index 98% rename from slides/creators/wrapper.tex rename to slides/creators/coding_wrappers.tex index f36153e..ae549bb 100644 --- a/slides/creators/wrapper.tex +++ b/slides/creators/coding_wrappers.tex @@ -1,8 +1,8 @@ -\input{common/wrapper} -\subsection*{Advanced} -\begin{frame}{Creating New Wrappers} +\section{Coding own Wrappers} + +\begin{frame}{Creating new Wrappers} Creating snakemake wrappers is as easy as creating the three constituent parts: \begin{description}[<+->] \item[\texttt{meta.yaml}:] A documentation file, containing information about the tool and the wrapper From c1a7372b21390ff30408e0bd10ed327a4e107bc0 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 15:37:13 +0100 Subject: [PATCH 06/12] common/using_wrappers - introduced consistent usage of the Snakemake layout --- slides/common/using_wrappers.tex | 74 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/slides/common/using_wrappers.tex b/slides/common/using_wrappers.tex index 495c433..644ed9e 100644 --- a/slides/common/using_wrappers.tex +++ b/slides/common/using_wrappers.tex @@ -15,35 +15,35 @@ \section{Snakemake Wrappers} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\subsection{Basics} +\subsection{Using Wrappers} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{What is this about?} \begin{question}[Questions] \begin{itemize} - \item What is a snakemake Wrapper? - \item How can snakemake wrappers be used to write reproducible workflows? + \item What is a Snakemake Wrapper? + \item How can Snakemake wrappers be used to write reproducible workflows? \end{itemize} \end{question} \begin{docs}[Objectives] \begin{enumerate} - \item Introduce the concept of snakemake wrappers - \item Include snakemake wrappers in your workflows - \item Reproducibility of snakemake wrappers + \item Introduce the concept of Snakemake wrappers + \item Include Snakemake wrappers in your workflows + \item Reproducibility of Snakemake wrappers \end{enumerate} \end{docs} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Introduction to Wrappers} - For a single tool, Snakemake Wrappers do: + For a single tool, \Snakemake{} Wrappers do: \begin{itemize}[<+->] \item Document usage \item Describe the dependencies - \item Provide a way to call the tool with information from snakemake + \item Provide a way to call the tool with information from Snakemake \end{itemize} - This setup makes snakemake wrappers reusable across multiple workflows. + This setup makes Snakemake wrappers reusable across multiple workflows. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -60,7 +60,7 @@ \subsection{Basics} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers} - Using snakemake wrappers can be achieved easily: + Using \Snakemake{} wrappers can be achieved easily: \begin{lstlisting}[language=Python,style=Python] rule bwa_map: input: @@ -78,7 +78,7 @@ \subsection{Basics} "v3.2.0/bio/bwa/mem" \end{lstlisting} \begin{docs} - This example uses the community snakemake-wrappers repository \altverb{bwa-mem} wrapper. + This example uses the community Snakemake wrappers repository \altverb{bwa-mem} wrapper. \end{docs} \end{frame} @@ -118,34 +118,34 @@ \subsection{Basics} \altverb{bwa-mem} supports custom arguments like \altverb{sort_order} and the common \altverb{extra} flag, that is used to supply command line parameters for the invocation of the tool. The \altverb{threads} and \altverb{resources} - settings from a snakemake rule are also commonly used to set memory or parallelization + settings from a Snakemake rule are also commonly used to set memory or parallelization parameters for each tool. \end{docs} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} -% The \altverb{wrapper} directive signals that snakemake should execute this rule with -% a wrapper. -% \begin{lstlisting}[language=Python,style=Python] -% rule bwa_map: -% ... -% wrapper: -% "v3.2.0/bio/bwa/mem" -% \end{lstlisting} -% \begin{docs} -% The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} -% flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. -% \end{docs} -% \end{frame} -% -% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \begin{frame}{Advantages of Wrappers} -% Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: -% \begin{itemize}[<+->] -% \item Code is reusable across workflows and can be shared with others -% \item Complex invocations of tools do not clutter your snakemake workflow definitions -% \item With versioned wrappers, you workflow is easily reproducible -% \item Community wrappers often get you started quickly using a new tool correctly -% \end{itemize} -% \end{frame} + \begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} + The \altverb{wrapper} directive signals that \Snakemake{} should execute this rule with + a wrapper. + \begin{lstlisting}[language=Python,style=Python] + rule bwa_map: + ... + wrapper: + "v3.2.0/bio/bwa/mem" + \end{lstlisting} + \begin{docs} + The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} + flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. + \end{docs} + \end{frame} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \begin{frame}{Advantages of Wrappers} + Using wrappers has many great advantages compared to \altverb{run} or \altverb{shell}: + \begin{itemize}[<+->] + \item Code is reusable across workflows and can be shared with others + \item Complex invocations of tools do not clutter your \Snakemake{} workflow definitions + \item With versioned wrappers, you workflow is easily reproducible + \item Community wrappers often get you started quickly using a new tool correctly + \end{itemize} + \end{frame} From 3fe7f2b520c06250870297c883aa385048290038 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 15:37:41 +0100 Subject: [PATCH 07/12] adapt_sections.py - will silently ignore configured tex files --- slides/adapt_sections.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/slides/adapt_sections.py b/slides/adapt_sections.py index 853f5e7..b344b60 100755 --- a/slides/adapt_sections.py +++ b/slides/adapt_sections.py @@ -49,8 +49,11 @@ def count_matching_lines(fp): def count_sections(file_list): count = 0 for fname in file_list: - with open(fname) as fp: - count += count_matching_lines(fp) + try: + with open(fname) as fp: + count += count_matching_lines(fp) + except: + print(f"Error treating: '{fname}'") return count def define_boundaries(section_count): @@ -62,8 +65,12 @@ def define_boundaries(section_count): def find_and_replace(boundaries, fname): # tex files aren't big, read all content in memory - with open(fname) as infile: - lines = infile.readlines() + try: + with open(fname) as infile: + lines = infile.readlines() + except: + print(f"Error treating: '{fname}'") + return # get the matching 'currentsection' lines first_done, second_done = False, False From ef6c3fec448ef0117ef50d7ad769800106100ac3 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 15:44:27 +0100 Subject: [PATCH 08/12] common/using_wrappers - changed wrapper doc URL to readthedocs-link --- slides/common/using_wrappers.tex | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/slides/common/using_wrappers.tex b/slides/common/using_wrappers.tex index 644ed9e..c812049 100644 --- a/slides/common/using_wrappers.tex +++ b/slides/common/using_wrappers.tex @@ -22,15 +22,15 @@ \subsection{Using Wrappers} \frametitle{What is this about?} \begin{question}[Questions] \begin{itemize} - \item What is a Snakemake Wrapper? - \item How can Snakemake wrappers be used to write reproducible workflows? + \item What is a \Snakemake{} Wrapper? + \item How can \Snakemake{} wrappers be used to write reproducible workflows? \end{itemize} \end{question} \begin{docs}[Objectives] \begin{enumerate} - \item Introduce the concept of Snakemake wrappers - \item Include Snakemake wrappers in your workflows - \item Reproducibility of Snakemake wrappers + \item Introduce the concept of \Snakemake{} wrappers + \item Include \Snakemake{} wrappers in your workflows + \item Reproducibility of \Snakemake{} wrappers \end{enumerate} \end{docs} \end{frame} @@ -55,7 +55,7 @@ \subsection{Using Wrappers} \item A python script that invokes the tool (\altverb{wrapper.py}) \end{enumerate} Since they are reusable, there is a large repository online of tried and tested - wrappers written by the community: \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} + wrappers written by the community: \lhref{https://snakemake-wrappers.readthedocs.io}{snakemake-wrappers}. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From e91a9312991e22227791b6218bd1f077d2f5652d Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 17:28:51 +0100 Subject: [PATCH 09/12] common/using_wrappers - re-arragned and corrected layout - better didactics? --- slides/common/using_wrappers.tex | 94 ++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 34 deletions(-) diff --git a/slides/common/using_wrappers.tex b/slides/common/using_wrappers.tex index c812049..ea5edb7 100644 --- a/slides/common/using_wrappers.tex +++ b/slides/common/using_wrappers.tex @@ -58,52 +58,95 @@ \subsection{Using Wrappers} wrappers written by the community: \lhref{https://snakemake-wrappers.readthedocs.io}{snakemake-wrappers}. \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile]{Using Wrappers - The Example} + \begin{docs} + The following example uses the \altverb{bwa-mem} wrapper from the \Snakemake-community wrappers repository. The example is specific and let us illustrate the usage. + We will cover the usage step by step and specifically: + \begin{itemize} + \item How to find a wrapper? + \item How to use a wrapper. + \end{itemize} + \end{docs} +\end{frame} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers} - Using \Snakemake{} wrappers can be achieved easily: - \begin{lstlisting}[language=Python,style=Python] + Using \Snakemake{} wrappers ease your life as a workflow programmer: + \begin{lstlisting}[language=Python,style=Python,basicstyle=\footnotesize] rule bwa_map: input: - reads=["input/{sample}_1.fq.gz", "input/{sample}_2.fq.gz"], - idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"), + reads=["input/{sample}_1.fq.gz", + "input/{sample}_2.fq.gz"], + idx=multiext("genome", ".amb", + ".ann", ".bwt", ".pac", ".sa"), output: "output/{sample}.bam" params: extra=r"-R '@RG\tID:{sample}\tSM:{sample}'", - sorting="none", # Can be 'none', 'samtools' or 'picard'. - sort_order="queryname", # Can be 'queryname' or 'coordinate'. - sort_extra="", # Extra args for samtools/picard. + sorting="none", + sort_order="queryname", + sort_extra="", threads: 8 wrapper: "v3.2.0/bio/bwa/mem" \end{lstlisting} - \begin{docs} - This example uses the community Snakemake wrappers repository \altverb{bwa-mem} wrapper. - \end{docs} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} + The \altverb{wrapper} directive signals that \Snakemake{} should execute this rule with + a wrapper. + \begin{lstlisting}[language=Python,style=Python,basicstyle=\small] +rule bwa_map: + ... + @wrapper:@ + @"v3.2.0/bio/bwa/mem"@ + \end{lstlisting} + \begin{docs} + \begin{columns} + \begin{column}{0.5\textwidth} + Here, we instruct the code to run with the \altverb{wrapper}-directive. + It specifies + \begin{itemize} + \item a version + \item a directory + \item and selects a tool. + \end{itemize} + \end{column} + \begin{column}{0.5\textwidth}\pause + The path to the tool is given relative to the workflow or a path given by the \altverb{--wrapper-prefix} + flag. By default \Snakemake automatically downloads wrappers from the \lhref{https://github.com/snakemake/snakemake-wrappers}{wrappers} repository. + \end{column} + \end{columns} + \end{docs} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers: In- and Output} - Input and Output of the rules has to match the definition of the snakemake wrapper. - \begin{lstlisting}[language=Python,style=Python] + \altverb{input} and \altverb{output} of the rules has to match the definition of the wrapper: + \begin{lstlisting}[language=Python,style=Python,basicstyle=\tiny] rule bwa_map: input: - reads=["input/{sample}_1.fq.gz", "input/{sample}_2.fq.gz"], - idx=multiext("genome", ".amb", ".ann", ".bwt", ".pac", ".sa"), + reads=["input/{sample}_1.fq.gz", + "input/{sample}_2.fq.gz"], + idx=multiext("genome", ".amb", ".ann", + ".bwt", ".pac", ".sa"), output: "output/{sample}.bam" ... \end{lstlisting} \begin{docs} The \altverb{bwa-mem} wrapper expects an input object with two attributes - \altverb{reads} and \altverb{idx} and writes to a single output file. + \altverb{reads} and \altverb{idx} and writes to a single output file.\newline + The example builds on short reads (hence: 2 inputs) and the \altverb{multiext}-directive allows samples to have multiple different extensions. \end{docs} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Using Wrappers: Parameters} Parameters may be used by wrappers to influence the behaviour, settings or resource usage. - \begin{lstlisting}[language=Python,style=Python] + \begin{lstlisting}[language=Python,style=Python,basicstyle=\tiny] rule bwa_map: ... params: @@ -118,26 +161,9 @@ \subsection{Using Wrappers} \altverb{bwa-mem} supports custom arguments like \altverb{sort_order} and the common \altverb{extra} flag, that is used to supply command line parameters for the invocation of the tool. The \altverb{threads} and \altverb{resources} - settings from a Snakemake rule are also commonly used to set memory or parallelization - parameters for each tool. + settings from a Snakemake rule are also commonly used to set memory or parallelization parameters for each tool. \end{docs} \end{frame} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \begin{frame}[fragile]{Using Wrappers: Calling a Wrapper} - The \altverb{wrapper} directive signals that \Snakemake{} should execute this rule with - a wrapper. - \begin{lstlisting}[language=Python,style=Python] - rule bwa_map: - ... - wrapper: - "v3.2.0/bio/bwa/mem" - \end{lstlisting} - \begin{docs} - The path to the tool is given relative to the repository or path given by the \altverb{--wrapper-prefix} - flag, which defaults to the \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers} repository. - \end{docs} - \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Advantages of Wrappers} From 37c6fbfc7ffb6acfae17dd12ccd277e26b61b991 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 17:29:31 +0100 Subject: [PATCH 10/12] Snakemake_HPC_Creators - including using and coding wrappers --- slides/Snakemake_HPC_Creators.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slides/Snakemake_HPC_Creators.tex b/slides/Snakemake_HPC_Creators.tex index a33f5a3..dab41e9 100644 --- a/slides/Snakemake_HPC_Creators.tex +++ b/slides/Snakemake_HPC_Creators.tex @@ -77,6 +77,8 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \include{common/using_wrappers} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \include{creators/coding_wrappers} \end{document} From 92d4ca9c9ef48657094290d6cebb52dd682a4be7 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Thu, 1 Feb 2024 17:31:04 +0100 Subject: [PATCH 11/12] creators/coding_wrappers - added frame separators --- slides/creators/coding_wrappers.tex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/slides/creators/coding_wrappers.tex b/slides/creators/coding_wrappers.tex index ae549bb..5747f63 100644 --- a/slides/creators/coding_wrappers.tex +++ b/slides/creators/coding_wrappers.tex @@ -1,7 +1,7 @@ - - +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Coding own Wrappers} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Creating new Wrappers} Creating snakemake wrappers is as easy as creating the three constituent parts: \begin{description}[<+->] @@ -41,6 +41,7 @@ \section{Coding own Wrappers} } \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Creating New Wrappers: Python Code} \altverb{wrapper.py} is the core component of any wrapper as it takes care of running the actual program. @@ -92,6 +93,7 @@ \section{Coding own Wrappers} \end{hint} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile]{Creating New Wrappers: Helper Functions} Snakemake provides several helper functions that make it easier to code wrappers. \begin{lstlisting}[language=Python,style=Python,gobble=8] @@ -108,6 +110,7 @@ \section{Coding own Wrappers} \end{lstlisting} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Assembling the new Wrapper} With these ingredients, you can write wrappers for your own tools. Recap of the steps required to create a new wrapper: @@ -122,6 +125,7 @@ \section{Coding own Wrappers} \end{docs} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}{Contributing Wrappers to the Community} New wrappers are always welcome at \lhref{https://github.com/snakemake/snakemake-wrappers}{snakemake-wrappers}. In order to contribute a new wrapper, please provide: From f02335cf04f793ab30ecbff4c7a6bda5e4f548dd Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Fri, 2 Feb 2024 11:05:06 +0100 Subject: [PATCH 12/12] Snakemake_HPC_Creators.tex - outcommented the creation of wrappers - too much for this course --- slides/Snakemake_HPC_Creators.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slides/Snakemake_HPC_Creators.tex b/slides/Snakemake_HPC_Creators.tex index dab41e9..362e866 100644 --- a/slides/Snakemake_HPC_Creators.tex +++ b/slides/Snakemake_HPC_Creators.tex @@ -79,6 +79,6 @@ \include{common/using_wrappers} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\include{creators/coding_wrappers} +%\include{creators/coding_wrappers} \end{document}