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

Removed Python 2 support.

parent 0fa4fca3
"""
backtranslate: Functions for reverse translation.
from os.path import dirname, abspath
from configparser import ConfigParser
Copyright (c) 2015 Leiden University Medical Center <humgen@lumc.nl>
Copyright (c) 2015 Jeroen F.J. Laros <j.f.j.laros@lumc.nl>
from .backtranslate import BackTranslate
Licensed under the MIT license, see the LICENSE file.
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals)
from future.builtins import str, zip
config = ConfigParser()
with open('{}/setup.cfg'.format(dirname(abspath(__file__)))) as handle:
config.read_file(handle)
__version_info__ = ('0', '1', '0')
_copyright_notice = 'Copyright (c) {} {} <{}>'.format(
config.get('metadata', 'copyright'),
config.get('metadata', 'author'),
config.get('metadata', 'author_email'))
__version__ = '.'.join(__version_info__)
__author__ = 'LUMC, Jeroen F.J. Laros'
__contact__ = 'J.F.J.Laros@lumc.nl'
__homepage__ = 'https://github.com/mutalyzer/backtranslate'
usage = __doc__.split("\n\n\n")
usage = [config.get('metadata', 'description'), _copyright_notice]
def doc_split(func):
return func.__doc__.split("\n\n")[0]
return func.__doc__.split('\n\n')[0]
def version(name):
return "%s version %s\n\nAuthor : %s <%s>\nHomepage : %s" % (name,
__version__, __author__, __contact__, __homepage__)
return '{} version {}\n\n{}\nHomepage: {}'.format(
config.get('metadata', 'name'),
config.get('metadata', 'version'),
_copyright_notice,
config.get('metadata', 'url'))
from __future__ import (
absolute_import, division, print_function, unicode_literals)
from future.builtins import str, zip
from collections import defaultdict
from Bio.Data import CodonTable
......@@ -9,8 +5,7 @@ from Levenshtein import hamming
def cmp_subst(subst_1, subst_2):
"""
Compare two substitution sets.
"""Compare two substitution sets.
:arg dict subst_1: Substitution set.
:arg dict subst_2: Substitution set.
......@@ -28,8 +23,7 @@ def cmp_subst(subst_1, subst_2):
def reverse_translation_table(table_id=1):
"""
Calculate a reverse translation table.
"""Calculate a reverse translation table.
:arg int table_id: Translation table id.
......@@ -47,20 +41,16 @@ def reverse_translation_table(table_id=1):
class BackTranslate(object):
"""
Back translation.
"""
"""Back translation."""
def __init__(self, table_id=1):
"""
Initialise the class.
"""Initialise the class.
:arg int table_id: Translation table id.
"""
self._back_table = reverse_translation_table(table_id)
def _one_subst(self, substitutions, reference_codon, amino_acid):
"""
Find single nucleotide substitutions that given a reference codon
"""Find single nucleotide substitutions that given a reference codon
explains an observed amino acid.
:arg defaultdict(set) substitutions: Set of single nucleotide
......@@ -76,8 +66,7 @@ class BackTranslate(object):
(reference_codon[position], codon[position]))
def with_dna(self, reference_codon, amino_acid):
"""
Find single nucleotide substitutions that given a reference codon
"""Find single nucleotide substitutions that given a reference codon
explains an observed amino acid.
:arg str reference_codon: Original codon.
......@@ -93,9 +82,8 @@ class BackTranslate(object):
return dict(substitutions)
def without_dna(self, reference_amino_acid, amino_acid):
"""
Find single nucleotide substitutions that given a reference amino acid
explains an observed amino acid.
"""Find single nucleotide substitutions that given a reference amino
acid explains an observed amino acid.
:arg str reference_amino_acid: Original amino acid.
:arg str amino_acid: Observed amino acid.
......@@ -111,9 +99,8 @@ class BackTranslate(object):
return dict(substitutions)
def improvable(self):
"""
Calculate all pairs of amino acid substututions that can be improved by
looking at the underlying codon.
"""Calculate all pairs of amino acid substututions that can be improved
by looking at the underlying codon.
:returns list: List of improvable substitutions.
"""
......
../setup.cfg
\ No newline at end of file
from __future__ import (
absolute_import, division, print_function, unicode_literals)
from future.builtins import str, zip
from Bio.Data import IUPACData
def _three_to_one():
"""
The three letter to one letter table for amino acids including stop.
"""The three letter to one letter table for amino acids including stop.
:returns dict: Three letter to one letter amino acids table.
"""
......@@ -16,8 +11,7 @@ def _three_to_one():
def subst_to_cds(substitutions, offset):
"""
Convert a set of substitutions to CDS coordinates.
""" Convert a set of substitutions to CDS coordinates.
:arg dict substitutions: Set of single nucleotide substitutions indexed by
position.
......
[metadata]
name = backtranslate
version = 0.1.1
description = Functions for reverse translation.
long_description = file: README.rst
author = LUMC, Jeroen F.J. Laros
author_email = J.F.J.Laros@lumc.nl
url = https://github.com/mutalyzer/backtranslate
keywords = bioinformatics
license = MIT
classifiers =
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
copyright = 2015-2019
[options]
packages = find:
install_requires =
biopython
configparser
python-Levenshtein
[options.package_data]
backtranslate = setup.cfg
[options.entry_points]
console_scripts =
backtranslate = backtranslate.cli:main
import os
import sys
from setuptools import setup
package = 'backtranslate'
package_name = 'BackTranslate'
description = '{}: Functions for reverse translation.'.format(package_name)
documentation = 'README.md'
license = 'MIT License'
keywords = ['bioinformatics']
dependencies = ['biopython', 'future', 'python-Levenshtein']
develop_dependencies = ['fake-open', 'pytest', 'tox']
supported = [(2, 7), (3, 3), (3, 4)]
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: Bio-Informatics',
]
if sys.version_info < supported[0]:
raise Exception('{} requires Python {}.{} or higher.'.format(
package, *supported[0]))
if sys.version_info[:2] == supported[0]:
dependencies.extend(['argparse', 'importlib'])
# This is quite the hack, but we don't want to import our package from here
# since that's recipe for disaster (it might have some uninstalled
# dependencies, or we might import another already installed version).
distmeta = {}
for line in open(os.path.join(package, '__init__.py')):
try:
field, value = (x.strip() for x in line.split('='))
except ValueError:
continue
if field == '__version_info__':
value = value.strip('[]()')
value = '.'.join(x.strip(' \'"') for x in value.split(','))
else:
value = value.strip('\'"')
distmeta[field] = value
try:
with open(documentation) as readme:
long_description = readme.read()
except IOError:
long_description = 'See ' + distmeta['__homepage__']
language_string = 'Programming Language :: Python'
classifiers += [
'License :: OSI Approved :: {}'.format(license),
'Operating System :: OS Independent',
language_string,
'{} :: {}'.format(language_string, supported[0][0]),
'{} :: {}'.format(language_string, supported[-1][0])] + \
['{} :: {}.{}'.format(language_string, *version) for version in supported]
setup(
name=package_name,
version=distmeta['__version_info__'],
description=description,
long_description=long_description,
author=distmeta['__author__'],
author_email=distmeta['__contact__'],
url=distmeta['__homepage__'],
license=license,
platforms=['any'],
packages=[package],
install_requires=dependencies,
tests_require=develop_dependencies,
entry_points={
'console_scripts': ['{0} = {0}.cli:main'.format(package)]
},
classifiers=classifiers,
keywords=' '.join(keywords)
)
setup()
[tox]
envlist = py27,py34
envlist = py35, py36
[testenv]
commands = py.test
commands = py.test -W error
whitelist_externals = py.test
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