Commit b25e6e74 authored by Laros's avatar Laros
Browse files

Added lecture for Python course.

parent d49f2af0
../../submodules/presentation/Makefile
\ No newline at end of file
../../submodules/presentation/beamerthemelumc.sty
\ No newline at end of file
../../submodules/presentation-pics/pics/bin_parser_hld.dia
\ No newline at end of file
../../submodules/presentation-pics/pics/cyrillic_1.png
\ No newline at end of file
../../submodules/presentation-pics/pics/cyrillic_2.png
\ No newline at end of file
../../submodules/presentation-pics/pics/fam_re.ps
\ No newline at end of file
../../submodules/presentation/logos
\ No newline at end of file
../../submodules/presentation-pics/pics/mutalyzer_disambiguation.xcf
\ No newline at end of file
../../submodules/presentation-pics/pics/mutalyzer_disambiguation_result.xcf
\ No newline at end of file
../../submodules/presentation-pics/pics/nested.png
\ No newline at end of file
\documentclass[slidestop]{beamer}
\author{Jeroen F.J. Laros}
\title{Scientific programming using Python}
\providecommand{\mySubTitle}{Putting everything together}
\providecommand{\myConference}{Scientific programming using Python}
\providecommand{\myDate}{21-09-2017}
\providecommand{\myGroup}{}
\providecommand{\myDepartment}{Department of Human Genetics}
\providecommand{\myCenter}{Center for Human and Clinical Genetics}
\usetheme{lumc}
\begin{document}
% This disables the \pause command, handy in the editing phase.
%\renewcommand{\pause}{}
% Make the title slide.
\makeTitleSlide{\includegraphics[width=3.0cm]{python_logo}}
% First page of the presentation.
\section{Introduction}
\makeTableOfContents
\section{General tips}
\subsection{Packaging}
\begin{pframe}
PyPI, the Python Package Index.
\bigskip
Repository of software for Python.
\begin{itemize}
\item $117\!,423$ packages (september 2017).
\end{itemize}
\bigskip
\begin{lstlisting}[language=bash, caption=Software installation with
\lstinline{pip}.]
pip install tssv
\end{lstlisting}
Download and install the package including its dependencies.
\vfill
\permfoot{\url{https://pypi.python.org/pypi}}
\end{pframe}
\begin{pframe}
Making a package yourself is relatively easy.
\bigskip
Adding just a few files to your project:
\begin{itemize}
\item Installation script (a few lines): \lstinline{setup.py}.
\item Package metadata (optional): \lstinline{setup.cfg}.
\end{itemize}
\bigskip
Metadata contains:
\begin{itemize}
\item Name, version, description, keywords, classifiers, \ldots
\item List of additional files to be packaged.
\item Dependencies.
\end{itemize}
\vfill
\permfoot{\url{https://setuptools.readthedocs.io/en/latest/}}
\end{pframe}
\subsection{Automated tests}
\begin{pframe}
Write tests for your code:
\begin{itemize}
\item Adding a feature can break functionality elsewhere.
\item Porting your code is easier when tests are in place.
\end{itemize}
\bigskip
\begin{lstlisting}[language=python, caption=pytest example.]
def inc(x):
return x + 1
def test_inc():
assert inc(8) == 9
\end{lstlisting}
\bigskip
\vfill
\permfoot{\url{https://docs.pytest.org/en/latest/}}
\permfoot{\url{https://tox.readthedocs.io/en/latest/}}
\end{pframe}
\subsection{API documentation}
\begin{pframe}
Have your code and its documentation in one place.
\bigskip
\begin{lstlisting}[language=python, caption=Docstring example.]
def inc(x):
"""Increase a number by one.
:arg int x: Any number.
:returns int: x + 1
"""
return x + 1
\end{lstlisting}
\bigskip
Output in \color{LUMCDonkerblauw}
\href{https://docs.python.org/3/library/datetime.html}{HTML}\color{black},
PDF, Manual pages, \ldots
\vfill
\permfoot{\url{http://www.sphinx-doc.org/en/stable/}}
\end{pframe}
\subsection{PEP 8}
\begin{pframe}
Style guide for Python code.
\bigskip
Extensive set of recommendations about:
\begin{itemize}
\item Naming variables, functions, classes, \ldots
\item Writing comments.
\item Using whitespace and newlines.
\item Maximum line length and wrapping guidelines.
\item \ldots
\end{itemize}
\vfill
\permfoot{\url{https://www.python.org/dev/peps/pep-0008/}}
\end{pframe}
\subsection{Licensing}
\begin{pframe}
Open Source software is software with source code that anyone can inspect,
modify, and enhance.
\bigskip
All of the tools (and Python itself) discussed here are Open Source.
\bigskip
Put a license on your code to enable other people to use it.
\begin{itemize}
\item Code without a license is \emph{closed}.
\item Well known licenses include Apache, BSD, GPL, MIT, \ldots
\item Do not make your own license, it will be incompatible with other
licenses.
\end{itemize}
\vfill
\permfoot{\url{https://opensource.org/licenses}}
\end{pframe}
\section{Example packages}
\subsection{Mutalyzer}
\begin{pframe}
A curational tool for Locus Specific Mutation Databases.
\bigskip
Variant nomenclature checker applying the HGVS guidelines:
\begin{itemize}
\item Is the syntax of the variant description valid?
\item Does the reference sequence exist?
\item Is the variant possible on this reference sequence?
\item Is this variant description the recommended one?
\end{itemize}
\bigskip
Basic effect prediction.
\begin{itemize}
\item Is the description of the transcript product as expected?
\item Is the predicted protein as expected?
\end{itemize}
\vfill
\permfoot{\url{https://mutalyzer.nl}}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[width=\textwidth]{mutalyzer_disambiguation}
\end{center}
\caption{\bt{NM\_002001.2:c.9\_10delinsTGC}.}
\end{figure}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[width=\textwidth]{mutalyzer_disambiguation_result}
\end{center}
\caption{\bt{NM\_002001.2:c.12dup}.}
\end{figure}
\end{pframe}
\begin{pframe}
Mutalyzer is free:
\begin{itemize}
\item Open source (AGPL license).
\item Available via GitHub.
\end{itemize}
\bigskip
Available via the web:
\begin{itemize}
\item Interactive user interface.
\item Batch interface:
\begin{itemize}
\item CSV, XLS, ODS.
\end{itemize}
\item Webservices (to integrate in a pipeline):
\begin{itemize}
\item SOAP.
\item HTTP/RPC+JSON.
\end{itemize}
\end{itemize}
\vfill
\permfoot{\url{https://mutalyzer.nl}}\\
\permfoot{\url{https://github.com/mutalyzer/mutalyzer}}
\end{pframe}
\subsection{Nested}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[width=\textwidth]{nested}
\end{center}
\caption{Nested online editor.}
\end{figure}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.7\textheight]{fam_re}
\end{center}
\caption{A Cyrillic FAM file.}
\end{figure}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.3\textheight]{bin_parser_hld}
\end{center}
\caption{High level design of a general binary parser.}
\end{figure}
Specification separate from implementation.
\begin{itemize}
\item Specification of the basic types.
\item Specification of the global file structure.
\end{itemize}
\end{pframe}
\begin{pframe}
Structure: $259$ lines, types: $183$ lines.
\begin{lstlisting}[language=none, caption={Structure snippet.}]
- name: members
for: number_of_members
structure:
- name: surname
- name: forenames
- name: address
type: comment
- name: spouses
for: number_of_spouses
structure:
- name: id
type: int
- name: flags
type: relationship
- name: name
\end{lstlisting}
\end{pframe}
\begin{pframe}
Resulting output in YAML format.
\begin{lstlisting}[language=none, caption={Output snippet.}]
members:
- surname: 'Gambolputty'
forenames: 'Johann'
address: 'Ulm'
spouses:
- flags:
consanguineous: false
divorced: false
informal: false
separated: false
id: 2
name: ''
\end{lstlisting}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.7\textheight]{cyrillic_1}
\end{center}
\caption{Original pedigree.}
\end{figure}
\end{pframe}
\begin{pframe}
We can edit the YAML file and convert it back to FAM format.
\begin{lstlisting}[language=none, caption={Updating date of death field.}]
date_of_birth: unknown
date_of_death: defined
father_id: 0
flags:
blood: false
cells: false
committed_suicide: false
dna: false
hide_info: false
loop_breakpoint: false
\end{lstlisting}
\end{pframe}
\begin{pframe}
\begin{figure}[]
\begin{center}
\includegraphics[height=0.7\textheight]{cyrillic_2}
\end{center}
\caption{Edited pedigree.}
\end{figure}
\end{pframe}
% Make the acknowledgements slide.
\makeAcknowledgementsSlide{
\begin{tabular}{l}
Guy Allard\\
Jonathan Vis\\
Mark Santcroos\\
Mihai Lefter\\
\end{tabular}
}
\end{document}
../../submodules/presentation-pics/pics/python_logo.svg
\ No newline at end of file
Subproject commit 49bd4b899df12078e4c9e93e766960bb0d5bf951 Subproject commit 0fdfa62033731733222d41c46513cfaa74e0aa88
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment