\documentclass[12pt]{beamer}
\usepackage{listings}
\usepackage{courier}
%\usepackage{pxfonts}

\lstset{numbers=left, numberstyle=\tiny, stepnumber=1,firstnumber=1,
    numbersep=5pt,language=Python,
    stringstyle=\ttfamily,
    basewidth  = {.6em,0.6em},
    basicstyle=\ttfamily\scriptsize,breaklines=true, 
    showstringspaces=false,
    moredelim=[is][\bfseries]{[*}{*]}
}
\beamerdefaultoverlayspecification{<+->}
\usetheme{Boadilla}
\usefonttheme{professionalfonts}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\author{Stefan Richter}
\title{From PIPSA to MultiPIPSA}
\setbeamercovered{transparent} 
\setbeamertemplate{navigation symbols}{} 
\logo{} 
\institute{HITS gGmbH} 
\date{Feb. 28th, 2019} 
\subject{Introduction to the usage of MultiPIPSA} 
\newcommand\blfootnote[1]{%
  \begingroup
  \renewcommand\thefootnote{}\footnote{#1}%
  \addtocounter{footnote}{-1}%
  \endgroup
}
\begin{document}

\begin{frame}
\titlepage
\end{frame}

%\begin{frame}
%\tableofcontents
%\end{frame}
\section{PIPSA}
\begin{frame}{What is PIPSA}
\begin{itemize}
\item \underline{P}rotein \underline{I}nteraction \underline{P}roperty \underline{S}imilarity \underline{A}nalysis
\item Method developed by Blomberg N, Gabdoulline RR, Nilges M, and Wade 1999.
\item Compares interaction fields (electrostatic potential) on superimposed structures and calculates heatmap or cluster tree
\item Initially available as commandline tool,\\ since 2007 also as webserver: http://pipsa.h-its.org
\item Now presented here with extensions as a python module and as you see later by Lukas used in a jupyter notebook.
\end{itemize}
\end{frame}
\begin{frame}{PIPSA example}
\centerline{\includegraphics[width=0.4\textwidth]{m_gkn181f2.jpg}}\blfootnote{Stefan Richter, Anne Wenzel, Matthias Stein, Razif R. Gabdoulline, Rebecca C. Wade; Nucleic Acids Research, 2008}
\end{frame}
\section{Installation and Anaconda}
\begin{frame}[containsverbatim,fragile]{Prerequisites}
\begin{itemize}
\item<+-> Python 2 or 3 is possible, ideally use anaconda (see next slide).
\item<+-> Download multipipsa distribution, unpack
\item<+-> Installing multipipsa \\ \begin{lstlisting}[frame=single]
conda activate mypipsa
python setup.py install
\end{lstlisting}
\end{itemize}
\end{frame}
\begin{frame}[containsverbatim,fragile]{Use of Anaconda}
\begin{block}{Useful commands}
\begin{lstlisting}[frame=single]
   # Setting addition sources for packages in conda
conda config --add channels bioconda
   # Create an environment that uses python 3.4 as default 
conda create -n myenv python=3.4
   # Install the scipy package with a give version number
conda install -n myenv scipy=0.15.0
   # make all packages/interpreters installed in myenv available
conda activate myenv
   # Create a new environment based on an existing environment
conda create --name myclone --clone myenv
   # Write out the information about a specific environment to a file
conda list --explicit > spec-file.txt
   # Create an environemnt based on a file
conda create --name myenv --file spec-file.txt
   # Install into the current environement all packages from a file
conda install --name myenv --file spec-file.txt
   # List available environments from a conda installation
conda info --envs
   # Get rid of the conda environment
conda deactivate
\end{lstlisting}
\end{block}
\end{frame}
\section{Structure Preparation}
\begin{frame}[containsverbatim,fragile]{Example from \tt{multipipsa/testMultipipsa.py}}
Make sure, your structures are
\begin{block}{Running APBS}
\begin{lstlisting}[frame=single]
ingrp  = ["AC1", "AC5", "AC6"]
outgrp = ["AC2", "AC3", "AC4", "AC7", "AC8", "AC9"]
apbs = ApbsRun(
     dataDir=os.getcwd()+"/example/pdbs",
     temp=298.15,ios=0.100,structures=ingrp+outgrp)
apbs.runPdb2Pqr()
apbs.runApbs()
\end{lstlisting}
\end{block}
\end{frame}
\section{MultiPISA for standard PIPSA analysis}
\begin{frame}[containsverbatim,fragile]{}
\begin{block}{Standard PIPSA}
\begin{lstlisting}[frame=single,basicstyle=\ttfamily\scriptsize]
pr.runPipsa(ingrp+outgrp)
###############################################################
cl0 = ClusterPipsa(structures=ingrp+outgrp,pipsaRoot="../../pipsa",
          dataDir=os.getcwd()+"/example/pdbs", 
          distanceType=DistanceType.PIPSA,
          graphicsFileRoot="clust0")
pr.runClusterPipsa(ingrp+outgrp,
          points=[],cluster=cl0)
###############################################################
cl1 = ClusterPipsa(structures=ingrp+outgrp,pipsaRoot="../../pipsa",
          dataDir=os.getcwd()+"/example/pdbs", 
          distanceType=DistanceType.PIPSA,
          graphicsFileRoot="clust1")
pr.runClusterPipsa(ingrp+outgrp,
          points=pr.getStructure().getCAAtoms(),cluster=cl1)
###############################################################
cl2 = ClusterPipsa(structures=ingrp+outgrp,pipsaRoot="../../pipsa",
                      dataDir=os.getcwd()+"/example/pdbs", 
                      distanceType=DistanceType.PIPSA,
                      graphicsFileRoot="clust2")
pr.runClusterPipsa(ingrp+outgrp,
          points=pr.getStructure().getCAAtoms()[10],cluster=cl2)

\end{lstlisting}
\end{block}
\end{frame}
\begin{frame}{Standard PIPSA -- Results}
\centerline{\includegraphics<1>[width=0.6\textwidth]{clust0_1.png}}
\centerline{\includegraphics<2>[width=0.6\textwidth]{clust0_heat3_1.png}}
\end{frame}



\section{MultiPIPSA usage for binding analysis}

\begin{frame}[containsverbatim,fragile]{Example from \tt{multipipsa/testMultipipsa.py}}
\blfootnote{Tong, Wade and Bruce,  Comparative electrostatic analysis of adenylyl cyclase for isoform dependent regulation properties., Proteins 2016; 84:1844-1858;  doi: 10.1002/prot.25167.}
\begin{block}{Calculate Binding Scores}
Reproduces the Fig. 5 of the binding scores of the reference in the footnote below.
\begin{lstlisting}[frame=single]
pr = PipsaRun(pipsaRoot="../../pipsa",
     dataDir=os.getcwd()+"/example/pdbs",
     pointsTemplate="AC5")
pr.runBindingScorePipsa(ingrp, outgrp)
pr.savePDBResult(filename="SimHodgkin.pdb",
     scoreType=ScoreType.MS,
     similarityType=SimilarityType.HODGKIN)
\end{lstlisting}
\end{block}
\end{frame}

\begin{frame}[containsverbatim,fragile]{Score is saved in B-Factor column}
\begin{block}{Excerpt from SimHodgkin.pdb file of previous example}
\begin{lstlisting}[frame=single,breaklines=False,basicstyle=\ttfamily\tiny]
ATOM   2364  CZ  PHE B 300      38.312  -9.485  36.510  0.00  [*0.20*]           C  
ATOM   2365  N   GLN B 301      44.946  -8.363  34.106  0.00  [*0.38*]           N  
ATOM   2366  CA  GLN B 301      46.308  -8.562  33.712  0.00  [*0.38*]           C  
ATOM   2367  C   GLN B 301      46.943  -9.327  34.831  0.00  [*0.38*]           C  
ATOM   2368  O   GLN B 301      46.523  -9.218  35.981  0.00  [*0.38*]           O  
ATOM   2369  CB  GLN B 301      47.086  -7.243  33.560  0.00  [*0.38*]           C  
ATOM   2370  CG  GLN B 301      46.532  -6.335  32.460  0.00  [*0.38*]           C  
ATOM   2371  CD  GLN B 301      47.373  -5.066  32.412  0.00  [*0.38*]           C  
ATOM   2372  NE2 GLN B 301      47.920  -4.745  31.209  0.00  [*0.38*]           N  
ATOM   2373  OE1 GLN B 301      47.539  -4.378  33.417  0.00  [*0.38*]           O  
ATOM   2374  N   MET B 302      47.972 -10.137  34.521  0.00  [*0.44*]           N  
ATOM   2375  CA  MET B 302      48.602 -10.927  35.540  0.00  [*0.44*]           C  
ATOM   2376  C   MET B 302      49.886 -10.255  35.926  0.00  [*0.44*]           C  
\end{lstlisting}
\end{block}
\end{frame}

\begin{frame}{Visualization in pymol}
\centerline{\includegraphics[width=0.7\textwidth]{SimHodgkinSurface.png}}
Select surface representation in pymol and enter the command 
\texttt{spectrum b, red\_white\_blue, all, -1,1}
\end{frame}

\section{MultiPIPSA usage for cluster analysis}
\begin{frame}[containsverbatim,fragile]{Standard PIPSA -- Compare Result to given cluster}
\begin{block}{Standard PIPSA}
\begin{lstlisting}[frame=single]
referenceCluster = np.array([1,1,1,2,2,2,2,2,2])                                              
cl = ClusterPipsa(structures=ingrp+outgrp,pipsaRoot="../../pipsa", 
                      dataDir=os.getcwd()+"/example/pdbs", 
                      referenceCluster=referenceCluster,
                      distanceType=DistanceType.PIPSA,
                      graphicsFileRoot="clust")
pr.runClusterPipsa(ingrp+outgrp,cluster=cl)
pr.savePDBResult(filename="ClusterCorrectedRand.pdb",scoreType=ScoreType.CORRECTED_RAND,
                 clusterObject=cl)
\end{lstlisting}
\end{block}
\end{frame}

\begin{frame}{Standard PIPSA -- Areas with very similar clusters as the reference cluster}
\centerline{\includegraphics[width=0.6\textwidth]{CorrectedRand.png}}
\end{frame}

\begin{frame}{Standard PIPSA -- Areas with high or low information content in the clustering}
\centerline{\includegraphics[width=0.6\textwidth]{ClusterInfo.png}}
\end{frame}

\end{document}
