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

\PYG{c+c1}{\PYGZsh{} Note it might have been clearer to assign the track numbers explicitly...}
\PYG{k}{for} \PYG{n}{rec\PYGZus{}X}\PYG{p}{,} \PYG{n}{tn\PYGZus{}X}\PYG{p}{,} \PYG{n}{rec\PYGZus{}Y}\PYG{p}{,} \PYG{n}{tn\PYGZus{}Y}\PYG{p}{,} \PYG{n}{X\PYGZus{}vs\PYGZus{}Y} \PYG{o+ow}{in} \PYG{p}{[}
    \PYG{p}{(}\PYG{n}{A\PYGZus{}rec}\PYG{p}{,} \PYG{l+m+mi}{3}\PYG{p}{,} \PYG{n}{B\PYGZus{}rec}\PYG{p}{,} \PYG{l+m+mi}{2}\PYG{p}{,} \PYG{n}{A\PYGZus{}vs\PYGZus{}B}\PYG{p}{),}
    \PYG{p}{(}\PYG{n}{B\PYGZus{}rec}\PYG{p}{,} \PYG{l+m+mi}{2}\PYG{p}{,} \PYG{n}{C\PYGZus{}rec}\PYG{p}{,} \PYG{l+m+mi}{1}\PYG{p}{,} \PYG{n}{B\PYGZus{}vs\PYGZus{}C}\PYG{p}{),}
\PYG{p}{]:}
    \PYG{n}{track\PYGZus{}X} \PYG{o}{=} \PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{tracks}\PYG{p}{[}\PYG{n}{tn\PYGZus{}X}\PYG{p}{]}
    \PYG{n}{track\PYGZus{}Y} \PYG{o}{=} \PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{tracks}\PYG{p}{[}\PYG{n}{tn\PYGZus{}Y}\PYG{p}{]}
    \PYG{k}{for} \PYG{n}{score}\PYG{p}{,} \PYG{n}{id\PYGZus{}X}\PYG{p}{,} \PYG{n}{id\PYGZus{}Y} \PYG{o+ow}{in} \PYG{n}{X\PYGZus{}vs\PYGZus{}Y}\PYG{p}{:}
        \PYG{n}{feature\PYGZus{}X} \PYG{o}{=} \PYG{n}{get\PYGZus{}feature}\PYG{p}{(}\PYG{n}{rec\PYGZus{}X}\PYG{o}{.}\PYG{n}{features}\PYG{p}{,} \PYG{n}{id\PYGZus{}X}\PYG{p}{)}
        \PYG{n}{feature\PYGZus{}Y} \PYG{o}{=} \PYG{n}{get\PYGZus{}feature}\PYG{p}{(}\PYG{n}{rec\PYGZus{}Y}\PYG{o}{.}\PYG{n}{features}\PYG{p}{,} \PYG{n}{id\PYGZus{}Y}\PYG{p}{)}
        \PYG{n}{color} \PYG{o}{=} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{linearlyInterpolatedColor}\PYG{p}{(}
            \PYG{n}{colors}\PYG{o}{.}\PYG{n}{white}\PYG{p}{,} \PYG{n}{colors}\PYG{o}{.}\PYG{n}{firebrick}\PYG{p}{,} \PYG{l+m+mi}{0}\PYG{p}{,} \PYG{l+m+mi}{100}\PYG{p}{,} \PYG{n}{score}
        \PYG{p}{)}
        \PYG{n}{link\PYGZus{}xy} \PYG{o}{=} \PYG{n}{CrossLink}\PYG{p}{(}
            \PYG{p}{(}\PYG{n}{track\PYGZus{}X}\PYG{p}{,} \PYG{n}{feature\PYGZus{}X}\PYG{o}{.}\PYG{n}{location}\PYG{o}{.}\PYG{n}{start}\PYG{p}{,} \PYG{n}{feature\PYGZus{}X}\PYG{o}{.}\PYG{n}{location}\PYG{o}{.}\PYG{n}{end}\PYG{p}{),}
            \PYG{p}{(}\PYG{n}{track\PYGZus{}Y}\PYG{p}{,} \PYG{n}{feature\PYGZus{}Y}\PYG{o}{.}\PYG{n}{location}\PYG{o}{.}\PYG{n}{start}\PYG{p}{,} \PYG{n}{feature\PYGZus{}Y}\PYG{o}{.}\PYG{n}{location}\PYG{o}{.}\PYG{n}{end}\PYG{p}{),}
            \PYG{n}{color}\PYG{p}{,}
            \PYG{n}{colors}\PYG{o}{.}\PYG{n}{lightgrey}\PYG{p}{,}
        \PYG{p}{)}
        \PYG{n}{gd\PYGZus{}diagram}\PYG{o}{.}\PYG{n}{cross\PYGZus{}track\PYGZus{}links}\PYG{o}{.}\PYG{n}{append}\PYG{p}{(}\PYG{n}{link\PYGZus{}xy}\PYG{p}{)}
\end{Verbatim}
