Unverified Commit 591b3e30 authored by Jeroen F.J. Laros's avatar Jeroen F.J. Laros
Browse files

Package rename.

parent d60c01b3
*.egg-info
*.pyc
.cache/
.tox/
build/
dist/
docs/Makefile
docs/_build/
examples/.ipynb_checkpoints/
mutalyzer_backtranslate.egg-info
......@@ -5,14 +5,14 @@ Back translation
: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://readthedocs.org/projects/mutalyzer-backtranslate/badge/?version=latest
:target: https://mutalyzer-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/pypi/v/mutalyzer-backtranslate.svg
:target: https://pypi.org/project/mutalyzer-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
......@@ -30,4 +30,4 @@ nucleotides.
Please see ReadTheDocs_ for the latest documentation.
.. _ReadTheDocs: https://backtranslate.readthedocs.io
.. _ReadTheDocs: https://mutalyzer-backtranslate.readthedocs.io
API documentation
=================
Main library
------------
.. automodule:: mutalyzer_backtranslate.backtranslate
:members:
Utils
-----
.. automodule:: mutalyzer_backtranslate.util
:members:
import os
import subprocess
import sys
subprocess.call('pip install ..', shell=True)
from mutalyzer_backtranslate import _get_metadata
author = _get_metadata('Author')
copyright = _get_metadata('Author')
project = _get_metadata('Name')
release = _get_metadata('Version')
autoclass_content = 'both'
extensions = ['sphinx.ext.autodoc']
master_doc = 'index'
......@@ -8,4 +8,5 @@
install
usage
library
api
credits
......@@ -5,7 +5,7 @@ The software is distributed via PyPI_, it can be installed with ``pip``:
::
pip install backtranslate
pip install mutalyzer-backtranslate
From source
......@@ -21,5 +21,5 @@ the following commands.
pip install .
.. _PyPI: https://pypi.org/project/backtranslate/
.. _PyPI: https://pypi.org/project/mutalyzer-backtranslate/
.. _GitHub: https://github.com/mutalyzer/backtranslate
......@@ -6,7 +6,7 @@ nucleotides.
.. code:: python
>>> from backtranslate import BackTranslate
>>> from mutalyzer_backtranslate import BackTranslate
>>>
>>> # Create a class instance, optionally giving the translation table id.
>>> bt = BackTranslate()
......@@ -41,7 +41,7 @@ To get substitutions in a readable format, we can use the following:
.. code:: python
>>> from backtranslate.util import subst_to_cds
>>> from mutalyzer_backtranslate.util import subst_to_cds
>>>
>>> substitutions = bt.without_dna('W', '*')
>>>
......
%% Cell type:markdown id: tags:
# Back translation
%% Cell type:code id: tags:
``` python
%pylab inline
```
%% Output
Populating the interactive namespace from numpy and matplotlib
%% Cell type:code id: tags:
``` python
from collections import defaultdict
from backtranslate import BackTranslate
from backtranslate.util import protein_letters
from mutalyzer_backtranslate import BackTranslate
from mutalyzer_backtranslate.util import protein_letters
```
%% Cell type:markdown id: tags:
Create a reverse translation class instance.
%% Cell type:code id: tags:
``` python
bt = BackTranslate()
```
%% Cell type:markdown id: tags:
For each pair of amino acids, calculate the number of one-nucleotide substitutions that transform one amino acid into the other.
%% Cell type:code id: tags:
``` python
table = []
for i in protein_letters:
table.append([])
for j in protein_letters:
s = bt.without_dna(i, j)
table[-1].append(int(sum(list(map(len, s.values())))))
```
%% Cell type:markdown id: tags:
Visualise the resutling matrix.
%% Cell type:code id: tags:
``` python
imshow(table, interpolation='nearest')
xticks(range(21), protein_letters)
yticks(range(21), protein_letters)
set_cmap('cool')
colorbar();
```
%% Output
%% Cell type:markdown id: tags:
Visualise the distribution of values in the matrix.
%% Cell type:code id: tags:
``` python
d = defaultdict(int)
for row in table:
for element in row:
d[element] += 1
ind = sorted(d.keys())
values = []
for i in ind:
values.append(d[i])
bar(ind, values);
```
%% Output
%% Cell type:markdown id: tags:
Print some summaries.
%% Cell type:code id: tags:
``` python
total = 21 ** 2
total_p = total / 100
imperfect = sum(values[2:])
print('\n{} substitutions in total.'.format(total))
print('{:3} impossible substitutions ({:.2f}%).'.format(values[0], values[0] / total_p))
print('{:3} perfect substitutions ({:.2f}%).'.format(values[1], values[1] / total_p))
print('{:3} imperfect substitutions ({:.2f}%).'.format(imperfect, imperfect / total_p))
possible = sum(values[1:])
possible_p = possible / 100
print('\n{:3} possible substitutions, of which {:.2f}% is perfect and {:.2f}% is imperfect.'.format(
possible, values[1] / possible_p, imperfect / possible_p))
```
%% Output
441 substitutions in total.
252 impossible substitutions (57.14%).
130 perfect substitutions (29.48%).
59 imperfect substitutions (13.38%).
189 possible substitutions, of which 68.78% is perfect and 31.22% is imperfect.
......
......@@ -43,8 +43,7 @@ def reverse_translation_table(table_id=1):
class BackTranslate(object):
"""Back translation."""
def __init__(self, table_id=1):
"""Initialise the class.
"""
:arg int table_id: Translation table id.
"""
self._back_table = reverse_translation_table(table_id)
......
[metadata]
name = backtranslate
version = 0.1.2
name = mutalyzer_backtranslate
version = 0.1.3
description = Functions for reverse translation.
long_description = file: README.rst
author = LUMC, Jeroen F.J. Laros
......@@ -28,4 +28,4 @@ tests_require =
[options.entry_points]
console_scripts =
backtranslate = backtranslate.cli:main
backtranslate = mutalyzer_backtranslate.cli:main
"""Tests for the backtranslate.backtranslate module."""
from backtranslate.backtranslate import BackTranslate, cmp_subst
"""Tests for the backtranslate module."""
from mutalyzer_backtranslate.backtranslate import BackTranslate, cmp_subst
class TestParser(object):
......
......@@ -6,7 +6,7 @@ from io import StringIO
from fake_open import md5_check
from backtranslate import cli
from mutalyzer_backtranslate import cli
class TestParser(object):
......
Supports Markdown
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