<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Pretty-printing DNA and protein sequences with monoseq
monoseq is a Python library for pretty-printing DNA and protein sequences using a monospace font. It also provides a simple command line interface.
Sequences are pretty-printed in the traditional way using blocks of letters where each line is prefixed with the sequence position. User-specified regions are highlighted and the output format can be HTML or plaintext with optional styling using ANSI escape codes for use in a terminal.
Here we show how monoseq can be used in the IPython Notebook environment. See the monoseq documentation for more.
Note
Step1:  Block and line lengths
We can change the number of characters per block and the number of blocks per line.
Step2:  Annotations
Let's say we want to highlight two subsequences because they are conserved between species. We define each region as a tuple start,stop (zero-based, stop not included) and include this in the annotation argument.
Step3:  As a contrived example to show several levels of annotation, let's also annotate every 12th character and the middle third of the sequence.
Step5:  Custom styling
The default CSS that is applied can be overridden with the style argument.
<ASSISTANT_TASK:>
Python Code:
from monoseq.ipynb import Seq
s = ('cgcactcaaaacaaaggaagaccgtcctcgactgcagaggaagcaggaagctgtc'
     'ggcccagctctgagcccagctgctggagccccgagcagcggcatggagtccgtgg'
     'ccctgtacagctttcaggctacagagagcgacgagctggccttcaacaagggaga'
     'cacactcaagatcctgaacatggaggatgaccagaactggtacaaggccgagctc'
     'cggggtgtcgagggatttattcccaagaactacatccgcgtcaag')
Seq(s)
Explanation: Pretty-printing DNA and protein sequences with monoseq
monoseq is a Python library for pretty-printing DNA and protein sequences using a monospace font. It also provides a simple command line interface.
Sequences are pretty-printed in the traditional way using blocks of letters where each line is prefixed with the sequence position. User-specified regions are highlighted and the output format can be HTML or plaintext with optional styling using ANSI escape codes for use in a terminal.
Here we show how monoseq can be used in the IPython Notebook environment. See the monoseq documentation for more.
Note: Some applications (e.g., GitHub) will not show the annotation styling in this notebook. View this notebook on nbviewer to see all styling.
Use in the IPython Notebook
If you haven't already done so, install monoseq using pip.
pip install monoseq
The monoseq.ipynb module provides Seq, a convenience wrapper around monoseq.pprint_sequence providing easy printing of sequence strings in an IPython Notebook.
End of explanation
Seq(s, block_length=8, blocks_per_line=8)
Explanation: Block and line lengths
We can change the number of characters per block and the number of blocks per line.
End of explanation
conserved = [(11, 37), (222, 247)]
Seq(s, annotations=[conserved])
Explanation: Annotations
Let's say we want to highlight two subsequences because they are conserved between species. We define each region as a tuple start,stop (zero-based, stop not included) and include this in the annotation argument.
End of explanation
twelves = [(p, p + 1) for p in range(11, len(s), 12)]
middle = [(len(s) / 3, len(s) / 3 * 2)]
Seq(s, annotations=[conserved, twelves, middle])
Explanation: As a contrived example to show several levels of annotation, let's also annotate every 12th character and the middle third of the sequence.
End of explanation
style = 
{selector} {{ background: beige; color: gray }}
{selector} .monoseq-margin {{ font-style: italic; color: green }}
{selector} .monoseq-annotation-0 {{ color: blue; font-weight: bold }}
Seq(s, style=style, annotations=[conserved])
Explanation: Custom styling
The default CSS that is applied can be overridden with the style argument.
End of explanation
<END_TASK>