{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Pretty-printing DNA and protein sequences with `monoseq`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[`monoseq`](https://github.com/martijnvermaat/monoseq/) is a Python library for pretty-printing DNA and protein sequences using a monospace font. It also provides a simple command line interface.\n", "\n", "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.\n", "\n", "Here we show how `monoseq` can be used in the IPython Notebook environment. See the `monoseq` [documentation](https://monoseq.readthedocs.org/) for more.\n", "\n", "**Note:** Some applications (e.g., GitHub) will not show the annotation styling in this notebook. [View this notebook on nbviewer](http://nbviewer.ipython.org/github/martijnvermaat/monoseq/blob/master/doc/monoseq.ipynb) to see all styling." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use in the IPython Notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you haven't already done so, install `monoseq` using `pip`.\n", "\n", " pip install monoseq\n", "\n", "The `monoseq.ipynb` module provides `Seq`, a convenience wrapper around `monoseq.pprint_sequence` providing easy printing of sequence strings in an IPython Notebook." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
1 cgcactcaaa acaaaggaag accgtcctcg actgcagagg aagcaggaag ctgtcggccc\n", " 61 agctctgagc ccagctgctg gagccccgag cagcggcatg gagtccgtgg ccctgtacag\n", "121 ctttcaggct acagagagcg acgagctggc cttcaacaag ggagacacac tcaagatcct\n", "181 gaacatggag gatgaccaga actggtacaa ggccgagctc cggggtgtcg agggatttat\n", "241 tcccaagaac tacatccgcg tcaag" ], "text/plain": [ "
1 cgcactca aaacaaag gaagaccg tcctcgac tgcagagg aagcagga agctgtcg gcccagct\n", " 65 ctgagccc agctgctg gagccccg agcagcgg catggagt ccgtggcc ctgtacag ctttcagg\n", "129 ctacagag agcgacga gctggcct tcaacaag ggagacac actcaaga tcctgaac atggagga\n", "193 tgaccaga actggtac aaggccga gctccggg gtgtcgag ggatttat tcccaaga actacatc\n", "257 cgcgtcaa g" ], "text/plain": [ "
1 cgcactcaaa acaaaggaag accgtcctcg actgcagagg aagcaggaag ctgtcggccc\n", " 61 agctctgagc ccagctgctg gagccccgag cagcggcatg gagtccgtgg ccctgtacag\n", "121 ctttcaggct acagagagcg acgagctggc cttcaacaag ggagacacac tcaagatcct\n", "181 gaacatggag gatgaccaga actggtacaa ggccgagctc cggggtgtcg agggatttat\n", "241 tcccaagaac tacatccgcg tcaag" ], "text/plain": [ "
1 cgcactcaaa acaaaggaag accgtcctcg actgcagagg aagcaggaag ctgtcggccc\n", " 61 agctctgagc ccagctgctg gagccccgag cagcggcatg gagtccgtgg ccctgtacag\n", "121 ctttcaggct acagagagcg acgagctggc cttcaacaag ggagacacac tcaagatcct\n", "181 gaacatggag gatgaccaga actggtacaa ggccgagctc cggggtgtcg agggatttat\n", "241 tcccaagaac tacatccgcg tcaag" ], "text/plain": [ "
1 cgcactcaaa acaaaggaag accgtcctcg actgcagagg aagcaggaag ctgtcggccc\n", " 61 agctctgagc ccagctgctg gagccccgag cagcggcatg gagtccgtgg ccctgtacag\n", "121 ctttcaggct acagagagcg acgagctggc cttcaacaag ggagacacac tcaagatcct\n", "181 gaacatggag gatgaccaga actggtacaa ggccgagctc cggggtgtcg agggatttat\n", "241 tcccaagaac tacatccgcg tcaag" ], "text/plain": [ "