\begin{Verbatim}[commandchars=\\\{\}]
\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{n}{table} \PYG{o}{=} \PYG{l+m+mi}{11}
\PYG{n}{min\PYGZus{}pro\PYGZus{}len} \PYG{o}{=} \PYG{l+m+mi}{100}


\PYG{k}{def} \PYG{n+nf}{find\PYGZus{}orfs\PYGZus{}with\PYGZus{}trans}\PYG{p}{(}\PYG{n}{seq}\PYG{p}{,} \PYG{n}{trans\PYGZus{}table}\PYG{p}{,} \PYG{n}{min\PYGZus{}protein\PYGZus{}length}\PYG{p}{):}
    \PYG{n}{answer} \PYG{o}{=} \PYG{p}{[]}
    \PYG{n}{seq\PYGZus{}len} \PYG{o}{=} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{seq}\PYG{p}{)}
    \PYG{k}{for} \PYG{n}{strand}\PYG{p}{,} \PYG{n}{nuc} \PYG{o+ow}{in} \PYG{p}{[(}\PYG{o}{+}\PYG{l+m+mi}{1}\PYG{p}{,} \PYG{n}{seq}\PYG{p}{),} \PYG{p}{(}\PYG{o}{\PYGZhy{}}\PYG{l+m+mi}{1}\PYG{p}{,} \PYG{n}{seq}\PYG{o}{.}\PYG{n}{reverse\PYGZus{}complement}\PYG{p}{())]:}
        \PYG{k}{for} \PYG{n}{frame} \PYG{o+ow}{in} \PYG{n+nb}{range}\PYG{p}{(}\PYG{l+m+mi}{3}\PYG{p}{):}
            \PYG{n}{trans} \PYG{o}{=} \PYG{n+nb}{str}\PYG{p}{(}\PYG{n}{nuc}\PYG{p}{[}\PYG{n}{frame}\PYG{p}{:]}\PYG{o}{.}\PYG{n}{translate}\PYG{p}{(}\PYG{n}{trans\PYGZus{}table}\PYG{p}{))}
            \PYG{n}{trans\PYGZus{}len} \PYG{o}{=} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{trans}\PYG{p}{)}
            \PYG{n}{aa\PYGZus{}start} \PYG{o}{=} \PYG{l+m+mi}{0}
            \PYG{n}{aa\PYGZus{}end} \PYG{o}{=} \PYG{l+m+mi}{0}
            \PYG{k}{while} \PYG{n}{aa\PYGZus{}start} \PYG{o}{\PYGZlt{}} \PYG{n}{trans\PYGZus{}len}\PYG{p}{:}
                \PYG{n}{aa\PYGZus{}end} \PYG{o}{=} \PYG{n}{trans}\PYG{o}{.}\PYG{n}{find}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}*\PYGZdq{}}\PYG{p}{,} \PYG{n}{aa\PYGZus{}start}\PYG{p}{)}
                \PYG{k}{if} \PYG{n}{aa\PYGZus{}end} \PYG{o}{==} \PYG{o}{\PYGZhy{}}\PYG{l+m+mi}{1}\PYG{p}{:}
                    \PYG{n}{aa\PYGZus{}end} \PYG{o}{=} \PYG{n}{trans\PYGZus{}len}
                \PYG{k}{if} \PYG{n}{aa\PYGZus{}end} \PYG{o}{\PYGZhy{}} \PYG{n}{aa\PYGZus{}start} \PYG{o}{\PYGZgt{}=} \PYG{n}{min\PYGZus{}protein\PYGZus{}length}\PYG{p}{:}
                    \PYG{k}{if} \PYG{n}{strand} \PYG{o}{==} \PYG{l+m+mi}{1}\PYG{p}{:}
                        \PYG{n}{start} \PYG{o}{=} \PYG{n}{frame} \PYG{o}{+} \PYG{n}{aa\PYGZus{}start} \PYG{o}{*} \PYG{l+m+mi}{3}
                        \PYG{n}{end} \PYG{o}{=} \PYG{n+nb}{min}\PYG{p}{(}\PYG{n}{seq\PYGZus{}len}\PYG{p}{,} \PYG{n}{frame} \PYG{o}{+} \PYG{n}{aa\PYGZus{}end} \PYG{o}{*} \PYG{l+m+mi}{3} \PYG{o}{+} \PYG{l+m+mi}{3}\PYG{p}{)}
                    \PYG{k}{else}\PYG{p}{:}
                        \PYG{n}{start} \PYG{o}{=} \PYG{n}{seq\PYGZus{}len} \PYG{o}{\PYGZhy{}} \PYG{n}{frame} \PYG{o}{\PYGZhy{}} \PYG{n}{aa\PYGZus{}end} \PYG{o}{*} \PYG{l+m+mi}{3} \PYG{o}{\PYGZhy{}} \PYG{l+m+mi}{3}
                        \PYG{n}{end} \PYG{o}{=} \PYG{n}{seq\PYGZus{}len} \PYG{o}{\PYGZhy{}} \PYG{n}{frame} \PYG{o}{\PYGZhy{}} \PYG{n}{aa\PYGZus{}start} \PYG{o}{*} \PYG{l+m+mi}{3}
                    \PYG{n}{answer}\PYG{o}{.}\PYG{n}{append}\PYG{p}{((}\PYG{n}{start}\PYG{p}{,} \PYG{n}{end}\PYG{p}{,} \PYG{n}{strand}\PYG{p}{,} \PYG{n}{trans}\PYG{p}{[}\PYG{n}{aa\PYGZus{}start}\PYG{p}{:}\PYG{n}{aa\PYGZus{}end}\PYG{p}{]))}
                \PYG{n}{aa\PYGZus{}start} \PYG{o}{=} \PYG{n}{aa\PYGZus{}end} \PYG{o}{+} \PYG{l+m+mi}{1}
    \PYG{n}{answer}\PYG{o}{.}\PYG{n}{sort}\PYG{p}{()}
    \PYG{k}{return} \PYG{n}{answer}


\PYG{n}{orf\PYGZus{}list} \PYG{o}{=} \PYG{n}{find\PYGZus{}orfs\PYGZus{}with\PYGZus{}trans}\PYG{p}{(}\PYG{n}{record}\PYG{o}{.}\PYG{n}{seq}\PYG{p}{,} \PYG{n}{table}\PYG{p}{,} \PYG{n}{min\PYGZus{}pro\PYGZus{}len}\PYG{p}{)}
\PYG{k}{for} \PYG{n}{start}\PYG{p}{,} \PYG{n}{end}\PYG{p}{,} \PYG{n}{strand}\PYG{p}{,} \PYG{n}{pro} \PYG{o+ow}{in} \PYG{n}{orf\PYGZus{}list}\PYG{p}{:}
    \PYG{k}{print}\PYG{p}{(}
        \PYG{l+s+s2}{\PYGZdq{}}\PYG{l+s+si}{\PYGZpc{}s}\PYG{l+s+s2}{...}\PYG{l+s+si}{\PYGZpc{}s}\PYG{l+s+s2}{ \PYGZhy{} length }\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{, strand }\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{, }\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{:}\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{\PYGZdq{}}
        \PYG{o}{\PYGZpc{}} \PYG{p}{(}\PYG{n}{pro}\PYG{p}{[:}\PYG{l+m+mi}{30}\PYG{p}{],} \PYG{n}{pro}\PYG{p}{[}\PYG{o}{\PYGZhy{}}\PYG{l+m+mi}{3}\PYG{p}{:],} \PYG{n+nb}{len}\PYG{p}{(}\PYG{n}{pro}\PYG{p}{),} \PYG{n}{strand}\PYG{p}{,} \PYG{n}{start}\PYG{p}{,} \PYG{n}{end}\PYG{p}{)}
    \PYG{p}{)}
\end{Verbatim}
