\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k}{def} \PYG{n+nf}{get\PYGZus{}feature}\PYG{p}{(}\PYG{n}{features}\PYG{p}{,} \PYG{n+nb}{id}\PYG{p}{,} \PYG{n}{tags}\PYG{o}{=}\PYG{p}{[}\PYG{l+s+s2}{\PYGZdq{}locus\PYGZus{}tag\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}gene\PYGZdq{}}\PYG{p}{]):}
    \PYG{l+s+sd}{\PYGZdq{}\PYGZdq{}\PYGZdq{}Search list of SeqFeature objects for an identifier under the given tags.\PYGZdq{}\PYGZdq{}\PYGZdq{}}
    \PYG{k}{for} \PYG{n}{f} \PYG{o+ow}{in} \PYG{n}{features}\PYG{p}{:}
        \PYG{k}{for} \PYG{n}{key} \PYG{o+ow}{in} \PYG{n}{tags}\PYG{p}{:}
            \PYG{c+c1}{\PYGZsh{} tag may not be present in this feature}
            \PYG{k}{for} \PYG{n}{x} \PYG{o+ow}{in} \PYG{n}{f}\PYG{o}{.}\PYG{n}{qualifiers}\PYG{o}{.}\PYG{n}{get}\PYG{p}{(}\PYG{n}{key}\PYG{p}{,} \PYG{p}{[]):}
                \PYG{k}{if} \PYG{n}{x} \PYG{o}{==} \PYG{n+nb}{id}\PYG{p}{:}
                    \PYG{k}{return} \PYG{n}{f}
    \PYG{k}{raise} \PYG{n+ne}{KeyError}\PYG{p}{(}\PYG{n+nb}{id}\PYG{p}{)}
\end{Verbatim}
