Skip to content

Commit 9c46d72

Browse files
committed
feat: better directory layout shown - added slide about logging functionality with Python
1 parent 0c3d5b4 commit 9c46d72

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

slides/creators/Decorating_the_Workflow.tex

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ \subsection{The Configuration File}
7474

7575

7676
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77-
\begin{frame}
77+
\begin{frame}[fragile]
7878
\frametitle{The Configuration File}
79-
If observed closely you have seen this file:\newline
79+
Please copy a sample configuration:
80+
\begin{lstlisting}[language=Bash, style=Shell]
81+
cp -r /projects/p_nhr_snakemake/solutions/config .
82+
\end{lstlisting}
83+
We now have:\newline
8084
{\tiny \DTsetlength{0.2em}{1em}{0.2em}{0.4pt}{.6pt}
8185
\texttt{\$ tree}
8286
\dirtree{%
8387
.1 /.
8488
.2 config.
85-
.3 samples.yaml .
89+
.3 config.yaml .
8690
.2 {other stuff}.
8791
}}
8892
\pause
@@ -412,6 +416,22 @@ \subsection{The Configuration File}
412416
\only<1->{A working solution is in \altverb{12_Snakemake_logs} in your solutions folder.}
413417
\end{frame}
414418

419+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420+
\begin{frame}[fragile]
421+
\frametitle{Using Logging Functionality in Python Scripts}
422+
We know how to use the \altverb{log} directive in a rule, yet our scripts?
423+
\pause
424+
\begin{lstlisting}[language=Python,style=Python]
425+
import sys
426+
427+
#somewhere before the actual code starts
428+
sys.stderr = sys.stdout = open(snakemake.log[0], "wt")
429+
\end{lstlisting}
430+
\begin{hint}
431+
Small scripts do not require \altverb{print()} or logging functionality. It would only clutter the terminal. Yet errors can be catched this way, even in job context.
432+
\end{hint}
433+
\end{frame}
434+
415435
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416436
\begin{frame}[fragile]
417437
\frametitle{Temporary Files}

0 commit comments

Comments
 (0)