Commit e8e7d740 authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros
Browse files

Updated documentation.

parent 1c72d805
# Back translation
This library provides functions for back translation from amino acids to
nucleotides.
```python
>>> from __future__ import unicode_literals
>>>
>>> from backtranslate.backtranslate import BackTranslate
>>>
>>> # Create a class instance, optionally giving the translation table id.
>>> bt = BackTranslate()
>>>
>>> # Find all substitutions that transform the codon 'TGG' into a stop codon.
>>> bt.with_dna('TGG', '*')
{1: set([('G', 'A')]), 2: set([('G', 'A')])}
```
Sometimes we do not have access to the DNA sequence so we have to find
possible substitutions from the amino acids directly.
```python
>>> # Find all substitutions that transform a Tryptophan into a stop codon.
>>> bt.without_dna('W', '*')
{1: set([('G', 'A')]), 2: set([('G', 'A')])}
```
To find out which substitution predictions can be improved by adding codon
information, use the following function.
```python
>>> bt.improvable()
set([('I', 'L'), ('R', 'W'), ('Q', 'H'), ('C', '*'), ('*', 'W'), ('K', 'N'),
('C', 'W'), ('S', 'R'), ('L', 'I'), ('*', 'S'), ('S', '*'), ('L', '*'),
('L', 'M'), ('L', 'F'), ('*', 'L'), ('D', 'E'), ('R', 'G'), ('S', 'C'),
('E', 'D'), ('R', 'S'), ('N', 'K'), ('H', 'Q'), ('S', 'T'), ('T', 'S'),
('G', 'R'), ('L', 'V'), ('I', 'M'), ('F', 'L'), ('*', 'Y'), ('Y', '*'),
('V', 'L'), ('R', '*')])
```
To get substitutions in a readable format, we can use the following:
```python
>>> from backtranslate.util import subst_to_cds
>>>
>>> substitutions = bt.without_dna('W', '*')
>>>
>>> # Transform the substitutions to CDS coordinates.
>>> subst_to_cds(substitutions, 12)
set([(15, 'G', 'A'), (14, 'G', 'A')])
```
## Command line interface
Use the command `backtranslate` to find substitutions that explain an amino
acid change:
```bash
$ backtranslate with_dna -o 210 data/mhv.fa - 1 Leu
1 A C
1 A T
```
If no reference is available, use the `without_dna` subcommand:
```bash
$ backtranslate without_dna - Asp 92 Tyr
274 G T
```
The command `find_stops` finds a list of positions and substitutions that lead
to stop codons. This list of destructive substitutions are useful when
analysing a pool of viral transcripts. Counting the appropriate nucleotides at
the given positions gives insight into how many transcripts are active.
```bash
$ backtranslate find_stops -o 210 data/mhv.fa -
216 A T
225 A T
230 C A
230 C G
243 A T
...
```
Back translation
================
.. image:: https://img.shields.io/github/last-commit/mutalyzer/backtranslate.svg :target: https://github.com/mutalyzer/backtranslate/graphs/commit-activity
.. image:: https://travis-ci.org/mutalyzer/backtranslate.svg?branch=master
:target: https://travis-ci.org/mutalyzer/backtranslate
.. image:: https://readthedocs.org/projects/simplerpc/badge/?version=latest
:target: https://backtranslate.readthedocs.io/en/latest
.. image:: https://img.shields.io/github/release-date/mutalyzer/backtranslate.svg
:target: https://github.com/mutalyzer/backtranslate/releases
.. image:: https://img.shields.io/github/release/mutalyzer/backtranslate.svg
:target: https://github.com/mutalyzer/backtranslate/releases
.. image:: https://img.shields.io/pypi/v/backtranslate.svg
:target: https://pypi.org/project/backtranslate/
.. image:: https://img.shields.io/github/languages/code-size/mutalyzer/backtranslate.svg
:target: https://github.com/mutalyzer/backtranslate
.. image:: https://img.shields.io/github/languages/count/mutalyzer/backtranslate.svg
:target: https://github.com/mutalyzer/backtranslate
.. image:: https://img.shields.io/github/languages/top/mutalyzer/backtranslate.svg
:target: https://github.com/mutalyzer/backtranslate
.. image:: https://img.shields.io/github/license/mutalyzer/backtranslate.svg
:target: https://raw.githubusercontent.com/mutalyzer/backtranslate/master/LICENSE.md
----
This library provides functions for back translation from amino acids to
nucleotides.
Please see ReadTheDocs_ for the latest documentation.
.. _ReadTheDocs: https://backtranslate.readthedocs.io
Contributors
============
- Jeroen F.J. Laros <jlaros@fixedpoint.nl> (Original author, maintainer)
- Martijn Vermaat <martijn@vermaat.name> (Continuous integration setup)
Find out who contributed:
::
git shortlog -s -e
.. include:: ../README.rst
.. toctree::
:maxdepth: 2
:caption: Contents:
introduction
install
usage
library
credits
Installation
============
The software is distributed via PyPI_, it can be installed with ``pip``:
::
pip install backtranslate
From source
-----------
The source is hosted on GitHub_, to install the latest development version, use
the following commands.
::
git clone https://github.com/mutalyzer/backtranslate.git
cd backtranslate
pip install .
.. _PyPI: https://pypi.org/project/backtranslate/
.. _GitHub: https://github.com/mutalyzer/backtranslate
Introduction
============
Library
=======
The library provides functions for back translation from amino acids to
nucleotides.
.. code:: python
>>> from backtranslate import BackTranslate
>>>
>>> # Create a class instance, optionally giving the translation table id.
>>> bt = BackTranslate()
>>>
>>> # Find all substitutions that transform the codon 'TGG' into a stop codon.
>>> bt.with_dna('TGG', '*')
{1: {('G', 'A')}, 2: {('G', 'A')}}
Sometimes we do not have access to the DNA sequence so we have to find possible
substitutions from the amino acids directly.
.. code:: python
>>> # Find all substitutions that transform a Tryptophan into a stop codon.
>>> bt.without_dna('W', '*')
{1: {('G', 'A')}, 2: {('G', 'A')}}
To find out which substitution predictions can be improved by adding codon
information, use the following function.
.. code:: python
>>> bt.improvable()
{('N', 'K'), ('R', 'W'), ('L', 'F'), ('D', 'E'), ('E', 'D'), ('C', 'W'),
('K', 'N'), ('Q', 'H'), ('C', '*'), ('I', 'L'), ('G', 'R'), ('F', 'L'),
('S', '*'), ('T', 'S'), ('*', 'S'), ('S', 'R'), ('R', 'S'), ('V', 'L'),
('R', 'G'), ('Y', '*'), ('S', 'T'), ('*', 'L'), ('*', 'W'), ('H', 'Q'),
('L', 'I'), ('I', 'M'), ('L', 'V'), ('L', 'M'), ('L', '*'), ('R', '*'),
('S', 'C'), ('*', 'Y')}
To get substitutions in a readable format, we can use the following:
.. code:: python
>>> from backtranslate.util import subst_to_cds
>>>
>>> substitutions = bt.without_dna('W', '*')
>>>
>>> # Transform the substitutions to CDS coordinates.
>>> subst_to_cds(substitutions, 12)
{(14, 'G', 'A'), (15, 'G', 'A')}
Usage
=====
Use the command ``backtranslate`` to find substitutions that explain an amino
acid change:
::
$ backtranslate with_dna -o 210 data/mhv.fa - 1 Leu
1 A C
1 A T
If no reference is available, use the ``without_dna`` subcommand:
::
$ backtranslate without_dna - Asp 92 Tyr
274 G T
The command ``find_stops`` finds a list of positions and substitutions that
lead to stop codons. This list of destructive substitutions are useful when
analysing a pool of viral transcripts. Counting the appropriate nucleotides at
the given positions gives insight into how many transcripts are active.
::
$ backtranslate find_stops -o 210 data/mhv.fa -
216 A T
225 A T
230 C A
230 C G
243 A T
...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment