\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kn}{from} \PYG{n+nn}{reportlab.lib} \PYG{k+kn}{import} \PYG{n}{colors}
\PYG{k+kn}{from} \PYG{n+nn}{reportlab.lib.units} \PYG{k+kn}{import} \PYG{n}{cm}
\PYG{k+kn}{from} \PYG{n+nn}{Bio.Graphics} \PYG{k+kn}{import} \PYG{n}{GenomeDiagram}
\PYG{k+kn}{from} \PYG{n+nn}{Bio} \PYG{k+kn}{import} \PYG{n}{SeqIO}

\PYG{n}{record} \PYG{o}{=} \PYG{n}{SeqIO}\PYG{o}{.}\PYG{n}{read}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}NC\PYGZus{}005816.gb\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}genbank\PYGZdq{}}\PYG{p}{)}

\PYG{c+c1}{\PYGZsh{} Create the feature set and its feature objects,}
\PYG{n}{gd\PYGZus{}feature\PYGZus{}set} \PYG{o}{=} \PYG{n}{GenomeDiagram}\PYG{o}{.}\PYG{n}{FeatureSet}\PYG{p}{()}
\PYG{k}{for} \PYG{n}{feature} \PYG{o+ow}{in} \PYG{n}{record}\PYG{o}{.}\PYG{n}{features}\PYG{p}{:}
    \PYG{k}{if} \PYG{n}{feature}\PYG{o}{.}\PYG{n}{type} \PYG{o}{!=} \PYG{l+s+s2}{\PYGZdq{}gene\PYGZdq{}}\PYG{p}{:}
        \PYG{c+c1}{\PYGZsh{} Exclude this feature}
        \PYG{k}{continue}
    \PYG{k}{if} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{gd\PYGZus{}feature\PYGZus{}set}\PYG{p}{)} \PYG{o}{\PYGZpc{}} \PYG{l+m+mi}{2} \PYG{o}{==} \PYG{l+m+mi}{0}\PYG{p}{:}
        \PYG{n}{color} \PYG{o}{=} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{blue}
    \PYG{k}{else}\PYG{p}{:}
        \PYG{n}{color} \PYG{o}{=} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{lightblue}
    \PYG{n}{gd\PYGZus{}feature\PYGZus{}set}\PYG{o}{.}\PYG{n}{add\PYGZus{}feature}\PYG{p}{(}\PYG{n}{feature}\PYG{p}{,} \PYG{n}{color}\PYG{o}{=}\PYG{n}{color}\PYG{p}{,} \PYG{n}{label}\PYG{o}{=}\PYG{k+kc}{True}\PYG{p}{)}
\PYG{c+c1}{\PYGZsh{} (this for loop is the same as in the previous example)}

\PYG{c+c1}{\PYGZsh{} Create a track, and a diagram}
\PYG{n}{gd\PYGZus{}track\PYGZus{}for\PYGZus{}features} \PYG{o}{=} \PYG{n}{GenomeDiagram}\PYG{o}{.}\PYG{n}{Track}\PYG{p}{(}\PYG{n}{name}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}Annotated Features\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram} \PYG{o}{=} \PYG{n}{GenomeDiagram}\PYG{o}{.}\PYG{n}{Diagram}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}Yersinia pestis biovar Microtus plasmid pPCP1\PYGZdq{}}\PYG{p}{)}

\PYG{c+c1}{\PYGZsh{} Now have to glue the bits together...}
\PYG{n}{gd\PYGZus{}track\PYGZus{}for\PYGZus{}features}\PYG{o}{.}\PYG{n}{add\PYGZus{}set}\PYG{p}{(}\PYG{n}{gd\PYGZus{}feature\PYGZus{}set}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{add\PYGZus{}track}\PYG{p}{(}\PYG{n}{gd\PYGZus{}track\PYGZus{}for\PYGZus{}features}\PYG{p}{,} \PYG{l+m+mi}{1}\PYG{p}{)}
\end{Verbatim}
