Skip to content

Commit

Permalink
adaptions for 03 cloze text - not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeesters committed Dec 4, 2023
1 parent b620893 commit b509659
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions slides/creators/A_First_Workflow.tex
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,17 @@ \subsection{A first Step or ``Rule''}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Further Workflow Decoration}\footnotesize
\texttt{Snakemake} allows generalizing rules by using named wildcards. Simply replace the \altverb{A} in the second input file and in the output file with the wildcard \altverb{\{sample\}}, to yield:
\frametitle{\HandsOn{Further Workflow Decoration}}
(Usually), experiments consists of more than one input, e.\,g. several replicas might be present.\newline
\begin{task}{Introducing the \altverb{sample} Wildcard}
\texttt{Snakemake} allows generalizing rules by using named wildcards, too. Simply replace the \altverb{A} in the second input file and in the output file with the wildcard \altverb{\{sample\}}.\newline
You may refer to the \pathtoclozure{03_Snakefile} template.
\end{task}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Further Workflow Decoration -- Solution}
\begin{lstlisting}[language=Python,style=Python,basicstyle=\footnotesize]
rule bwa_map:
input:
Expand All @@ -338,15 +347,10 @@ \subsection{A first Step or ``Rule''}
shell:
"bwa mem {input} | samtools view -Sb - > {output}"
\end{lstlisting}
When \texttt{Snakemake} determines that this rule can be applied to generate a target file by replacing the wildcard \altverb{\{sample\}} in the output file with an appropriate value, it will propagate that value to all occurrences of \altverb{\{sample\}} in the input files and thereby determine the necessary input for the resulting job.
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{One Caveat!}
\begin{alertblock}{Multiple Wildcards}
You can have multiple wildcards in your file paths, however, to avoid conflicts with other jobs of the same rule, \emph{all output files} of a rule \emph{have to contain exactly the same wildcards}.
\end{alertblock}
\begin{docs}{Background}
When \texttt{Snakemake} determines that this rule can be applied to generate a target file by replacing the wildcard \altverb{\{sample\}} in the output file with an appropriate value, it will propagate that value to all occurrences of \altverb{\{sample\}} in the input files and thereby determine the necessary input for the resulting job.\newline
\pathtosolution{03_Snakefile}
\end{docs}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -367,26 +371,48 @@ \subsection{A first Step or ``Rule''}
\end{lstlisting}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{One Caveat!}
\begin{alertblock}{Multiple Wildcards}
You can have multiple wildcards in your file paths, however, to avoid conflicts with other jobs of the same rule, \emph{all output files} of a rule \emph{have to contain exactly the same wildcards}.
\end{alertblock}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Sorting Alignments}
For later steps, we need the read alignments in the BAM files to be sorted. This can be achieved with the \lhref{https://www.htslib.org/}{\texttt{samtools}} \altverb{sort} command. We add the following rule beneath the \altverb{bwa_map} rule:
\begin{lstlisting}[language=Python,style=Python]
rule samtools_sort:
input:
"mapped_reads/{sample}.bam"
...
output:
"sorted_reads/{sample}.bam"
...
shell:
"samtools sort -T sorted_reads/{wildcards.sample} "
"-O bam {input} > {output}"
\end{lstlisting}
%TODO check cloze text correct?
\begin{task}
Please refer to your template \altverb{03_Snakefile}.
Please refer to your template \altverb{04_Snakefile}.
\end{task}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Using Wildcards}
\begin{lstlisting}[language=Python,style=Python]
rule samtools_sort:
input:
"mapped_reads/{sample}.bam"
output:
"sorted_reads/{sample}.bam"
shell:
"samtools sort -T sorted_reads/{wildcards.sample} "
"-O bam {input} > {output}"
\end{lstlisting}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{Using Wildcards}
Expand Down

0 comments on commit b509659

Please sign in to comment.