\begin{Verbatim}[commandchars=\\\{\}]
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{k}{for} \PYG{n}{hit} \PYG{o+ow}{in} \PYG{n}{blast\PYGZus{}qresult}\PYG{p}{[:}\PYG{l+m+mi}{5}\PYG{p}{]:}   \PYG{c+c1}{\PYGZsh{} id and sequence length of the first five hits}
\PYG{g+gp}{... }    \PYG{n+nb}{print}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}}\PYG{l+s+si}{\PYGZpc{}s}\PYG{l+s+s2}{ }\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{\PYGZdq{}} \PYG{o}{\PYGZpc{}} \PYG{p}{(}\PYG{n}{hit}\PYG{o}{.}\PYG{n}{id}\PYG{p}{,} \PYG{n}{hit}\PYG{o}{.}\PYG{n}{seq\PYGZus{}len}\PYG{p}{))}
\PYG{g+gp}{...}
\PYG{g+go}{gi|262205317|ref|NR\PYGZus{}030195.1| 61}
\PYG{g+go}{gi|301171311|ref|NR\PYGZus{}035856.1| 60}
\PYG{g+go}{gi|270133242|ref|NR\PYGZus{}032573.1| 85}
\PYG{g+go}{gi|301171322|ref|NR\PYGZus{}035857.1| 86}
\PYG{g+go}{gi|301171267|ref|NR\PYGZus{}035851.1| 80}

\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{sort\PYGZus{}key} \PYG{o}{=} \PYG{k}{lambda} \PYG{n}{hit}\PYG{p}{:} \PYG{n}{hit}\PYG{o}{.}\PYG{n}{seq\PYGZus{}len}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{n}{sorted\PYGZus{}qresult} \PYG{o}{=} \PYG{n}{blast\PYGZus{}qresult}\PYG{o}{.}\PYG{n}{sort}\PYG{p}{(}\PYG{n}{key}\PYG{o}{=}\PYG{n}{sort\PYGZus{}key}\PYG{p}{,} \PYG{n}{reverse}\PYG{o}{=}\PYG{k+kc}{True}\PYG{p}{,} \PYG{n}{in\PYGZus{}place}\PYG{o}{=}\PYG{k+kc}{False}\PYG{p}{)}
\PYG{g+gp}{\PYGZgt{}\PYGZgt{}\PYGZgt{} }\PYG{k}{for} \PYG{n}{hit} \PYG{o+ow}{in} \PYG{n}{sorted\PYGZus{}qresult}\PYG{p}{[:}\PYG{l+m+mi}{5}\PYG{p}{]:}
\PYG{g+gp}{... }    \PYG{n+nb}{print}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}}\PYG{l+s+si}{\PYGZpc{}s}\PYG{l+s+s2}{ }\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{\PYGZdq{}} \PYG{o}{\PYGZpc{}} \PYG{p}{(}\PYG{n}{hit}\PYG{o}{.}\PYG{n}{id}\PYG{p}{,} \PYG{n}{hit}\PYG{o}{.}\PYG{n}{seq\PYGZus{}len}\PYG{p}{))}
\PYG{g+gp}{...}
\PYG{g+go}{gi|397513516|ref|XM\PYGZus{}003827011.1| 6002}
\PYG{g+go}{gi|390332045|ref|XM\PYGZus{}776818.2| 4082}
\PYG{g+go}{gi|390332043|ref|XM\PYGZus{}003723358.1| 4079}
\PYG{g+go}{gi|356517317|ref|XM\PYGZus{}003527287.1| 3251}
\PYG{g+go}{gi|356543101|ref|XM\PYGZus{}003539954.1| 2936}
\end{Verbatim}
