\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k}{def} \PYG{n+nf}{get\PYGZus{}accession}\PYG{p}{(}\PYG{n}{record}\PYG{p}{):}
    \PYG{l+s+sd}{\PYGZdq{}\PYGZdq{}\PYGZdq{}\PYGZdq{}Given a SeqRecord, return the accession number as a string.}

\PYG{l+s+sd}{    e.g. \PYGZdq{}gi|2765613|emb|Z78488.1|PTZ78488\PYGZdq{} \PYGZhy{}\PYGZgt{} \PYGZdq{}Z78488.1\PYGZdq{}}
\PYG{l+s+sd}{    \PYGZdq{}\PYGZdq{}\PYGZdq{}}
    \PYG{n}{parts} \PYG{o}{=} \PYG{n}{record}\PYG{o}{.}\PYG{n}{id}\PYG{o}{.}\PYG{n}{split}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}|\PYGZdq{}}\PYG{p}{)}
    \PYG{k}{assert} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{parts}\PYG{p}{)} \PYG{o}{==} \PYG{l+m+mi}{5} \PYG{o+ow}{and} \PYG{n}{parts}\PYG{p}{[}\PYG{l+m+mi}{0}\PYG{p}{]} \PYG{o}{==} \PYG{l+s+s2}{\PYGZdq{}gi\PYGZdq{}} \PYG{o+ow}{and} \PYG{n}{parts}\PYG{p}{[}\PYG{l+m+mi}{2}\PYG{p}{]} \PYG{o}{==} \PYG{l+s+s2}{\PYGZdq{}emb\PYGZdq{}}
    \PYG{k}{return} \PYG{n}{parts}\PYG{p}{[}\PYG{l+m+mi}{3}\PYG{p}{]}
\end{Verbatim}
