\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{k+kn}{from} \PYG{n+nn}{Bio.SeqFeature} \PYG{k+kn}{import} \PYG{n}{SeqFeature}\PYG{p}{,} \PYG{n}{FeatureLocation}

\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{n}{gd\PYGZus{}diagram} \PYG{o}{=} \PYG{n}{GenomeDiagram}\PYG{o}{.}\PYG{n}{Diagram}\PYG{p}{(}\PYG{n}{record}\PYG{o}{.}\PYG{n}{id}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}track\PYGZus{}for\PYGZus{}features} \PYG{o}{=} \PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{new\PYGZus{}track}\PYG{p}{(}\PYG{l+m+mi}{1}\PYG{p}{,} \PYG{n}{name}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}Annotated Features\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}feature\PYGZus{}set} \PYG{o}{=} \PYG{n}{gd\PYGZus{}track\PYGZus{}for\PYGZus{}features}\PYG{o}{.}\PYG{n}{new\PYGZus{}set}\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}{sigil}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}ARROW\PYGZdq{}}\PYG{p}{,} \PYG{n}{color}\PYG{o}{=}\PYG{n}{color}\PYG{p}{,} \PYG{n}{label}\PYG{o}{=}\PYG{k+kc}{True}\PYG{p}{,} \PYG{n}{label\PYGZus{}size}\PYG{o}{=}\PYG{l+m+mi}{14}\PYG{p}{,} \PYG{n}{label\PYGZus{}angle}\PYG{o}{=}\PYG{l+m+mi}{0}
    \PYG{p}{)}

\PYG{c+c1}{\PYGZsh{} I want to include some strandless features, so for an example}
\PYG{c+c1}{\PYGZsh{} will use EcoRI recognition sites etc.}
\PYG{k}{for} \PYG{n}{site}\PYG{p}{,} \PYG{n}{name}\PYG{p}{,} \PYG{n}{color} \PYG{o+ow}{in} \PYG{p}{[}
    \PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}GAATTC\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}EcoRI\PYGZdq{}}\PYG{p}{,} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{green}\PYG{p}{),}
    \PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}CCCGGG\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}SmaI\PYGZdq{}}\PYG{p}{,} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{orange}\PYG{p}{),}
    \PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}AAGCTT\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}HindIII\PYGZdq{}}\PYG{p}{,} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{red}\PYG{p}{),}
    \PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}GGATCC\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}BamHI\PYGZdq{}}\PYG{p}{,} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{purple}\PYG{p}{),}
\PYG{p}{]:}
    \PYG{n}{index} \PYG{o}{=} \PYG{l+m+mi}{0}
    \PYG{k}{while} \PYG{k+kc}{True}\PYG{p}{:}
        \PYG{n}{index} \PYG{o}{=} \PYG{n}{record}\PYG{o}{.}\PYG{n}{seq}\PYG{o}{.}\PYG{n}{find}\PYG{p}{(}\PYG{n}{site}\PYG{p}{,} \PYG{n}{start}\PYG{o}{=}\PYG{n}{index}\PYG{p}{)}
        \PYG{k}{if} \PYG{n}{index} \PYG{o}{==} \PYG{o}{\PYGZhy{}}\PYG{l+m+mi}{1}\PYG{p}{:}
            \PYG{k}{break}
        \PYG{n}{feature} \PYG{o}{=} \PYG{n}{SeqFeature}\PYG{p}{(}\PYG{n}{FeatureLocation}\PYG{p}{(}\PYG{n}{index}\PYG{p}{,} \PYG{n}{index} \PYG{o}{+} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{site}\PYG{p}{)))}
        \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}{name}\PYG{o}{=}\PYG{n}{name}\PYG{p}{,}
            \PYG{n}{label}\PYG{o}{=}\PYG{k+kc}{True}\PYG{p}{,}
            \PYG{n}{label\PYGZus{}size}\PYG{o}{=}\PYG{l+m+mi}{10}\PYG{p}{,}
            \PYG{n}{label\PYGZus{}color}\PYG{o}{=}\PYG{n}{color}\PYG{p}{,}
        \PYG{p}{)}
        \PYG{n}{index} \PYG{o}{+=} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{site}\PYG{p}{)}

\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{draw}\PYG{p}{(}\PYG{n+nb}{format}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}linear\PYGZdq{}}\PYG{p}{,} \PYG{n}{pagesize}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}A4\PYGZdq{}}\PYG{p}{,} \PYG{n}{fragments}\PYG{o}{=}\PYG{l+m+mi}{4}\PYG{p}{,} \PYG{n}{start}\PYG{o}{=}\PYG{l+m+mi}{0}\PYG{p}{,} \PYG{n}{end}\PYG{o}{=}\PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{record}\PYG{p}{))}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}linear\PYGZus{}nice.pdf\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}PDF\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}linear\PYGZus{}nice.eps\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}EPS\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}linear\PYGZus{}nice.svg\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}SVG\PYGZdq{}}\PYG{p}{)}

\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{draw}\PYG{p}{(}
    \PYG{n+nb}{format}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}circular\PYGZdq{}}\PYG{p}{,}
    \PYG{n}{circular}\PYG{o}{=}\PYG{k+kc}{True}\PYG{p}{,}
    \PYG{n}{pagesize}\PYG{o}{=}\PYG{p}{(}\PYG{l+m+mi}{20} \PYG{o}{*} \PYG{n}{cm}\PYG{p}{,} \PYG{l+m+mi}{20} \PYG{o}{*} \PYG{n}{cm}\PYG{p}{),}
    \PYG{n}{start}\PYG{o}{=}\PYG{l+m+mi}{0}\PYG{p}{,}
    \PYG{n}{end}\PYG{o}{=}\PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{record}\PYG{p}{),}
    \PYG{n}{circle\PYGZus{}core}\PYG{o}{=}\PYG{l+m+mf}{0.5}\PYG{p}{,}
\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}circular\PYGZus{}nice.pdf\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}PDF\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}circular\PYGZus{}nice.eps\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}EPS\PYGZdq{}}\PYG{p}{)}
\PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}plasmid\PYGZus{}circular\PYGZus{}nice.svg\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}SVG\PYGZdq{}}\PYG{p}{)}
\end{Verbatim}
