\begin{Verbatim}[commandchars=\\\{\}]
\PYG{k+kn}{import} \PYG{n+nn}{random}
\PYG{k+kn}{from} \PYG{n+nn}{Bio.Seq} \PYG{k+kn}{import} \PYG{n}{Seq}
\PYG{k+kn}{from} \PYG{n+nn}{Bio.SeqRecord} \PYG{k+kn}{import} \PYG{n}{SeqRecord}
\PYG{k+kn}{from} \PYG{n+nn}{Bio} \PYG{k+kn}{import} \PYG{n}{SeqIO}

\PYG{n}{original\PYGZus{}rec} \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{k}{with} \PYG{n+nb}{open}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}shuffled.fasta\PYGZdq{}}\PYG{p}{,} \PYG{l+s+s2}{\PYGZdq{}w\PYGZdq{}}\PYG{p}{)} \PYG{k}{as} \PYG{n}{output\PYGZus{}handle}\PYG{p}{:}
    \PYG{k}{for} \PYG{n}{i} \PYG{o+ow}{in} \PYG{n+nb}{range}\PYG{p}{(}\PYG{l+m+mi}{30}\PYG{p}{):}
        \PYG{n}{nuc\PYGZus{}list} \PYG{o}{=} \PYG{n+nb}{list}\PYG{p}{(}\PYG{n}{original\PYGZus{}rec}\PYG{o}{.}\PYG{n}{seq}\PYG{p}{)}
        \PYG{n}{random}\PYG{o}{.}\PYG{n}{shuffle}\PYG{p}{(}\PYG{n}{nuc\PYGZus{}list}\PYG{p}{)}
        \PYG{n}{shuffled\PYGZus{}rec} \PYG{o}{=} \PYG{n}{SeqRecord}\PYG{p}{(}
            \PYG{n}{Seq}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}\PYGZdq{}}\PYG{o}{.}\PYG{n}{join}\PYG{p}{(}\PYG{n}{nuc\PYGZus{}list}\PYG{p}{),} \PYG{n}{original\PYGZus{}rec}\PYG{o}{.}\PYG{n}{seq}\PYG{o}{.}\PYG{n}{alphabet}\PYG{p}{),}
            \PYG{n+nb}{id}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}Shuffled}\PYG{l+s+si}{\PYGZpc{}i}\PYG{l+s+s2}{\PYGZdq{}} \PYG{o}{\PYGZpc{}} \PYG{p}{(}\PYG{n}{i} \PYG{o}{+} \PYG{l+m+mi}{1}\PYG{p}{),}
            \PYG{n}{description}\PYG{o}{=}\PYG{l+s+s2}{\PYGZdq{}Based on }\PYG{l+s+si}{\PYGZpc{}s}\PYG{l+s+s2}{\PYGZdq{}} \PYG{o}{\PYGZpc{}} \PYG{n}{original\PYGZus{}rec}\PYG{o}{.}\PYG{n}{id}\PYG{p}{,}
        \PYG{p}{)}
        \PYG{n}{out\PYGZus{}handle}\PYG{o}{.}\PYG{n}{write}\PYG{p}{(}\PYG{n}{shuffled\PYGZus{}rec}\PYG{o}{.}\PYG{n}{format}\PYG{p}{(}\PYG{l+s+s2}{\PYGZdq{}fasta\PYGZdq{}}\PYG{p}{))}
\end{Verbatim}
