Skip to content

Commit c349c0e

Browse files
committed
added gitignore, deleted some ignored files
1 parent 89dc0ad commit c349c0e

File tree

10 files changed

+100
-101
lines changed

10 files changed

+100
-101
lines changed

python_codon_tables/.gitignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
*.py[cod]
2+
3+
# C extensions
4+
*.so
5+
6+
# Packages
7+
*.egg
8+
*.egg-info
9+
*.tar.gz
10+
dist
11+
build
12+
eggs
13+
parts
14+
bin
15+
var
16+
sdist
17+
develop-eggs
18+
.installed.cfg
19+
lib
20+
lib64
21+
__pycache__
22+
23+
# Sublime
24+
.sublime-project
25+
26+
# Installer logs
27+
pip-log.txt
28+
29+
# Unit test / coverage reports
30+
.coverage
31+
.tox
32+
nosetests.xml
33+
34+
# Translations
35+
*.mo
36+
37+
# Mr Developer
38+
.mr.developer.cfg
39+
.project
40+
.pydevproject
41+
42+
# Temp files
43+
44+
*~
45+
46+
# Pipy codes
47+
48+
.pypirc
49+
50+
examples/reports
51+
examples/features/downloaded_data
52+
53+
.cache

python_codon_tables/README.rst

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,6 @@ and here is the original paper to cite:
2828
status for the year 2000.
2929
Nakamura, Y., Gojobori, T. and Ikemura, T. (2000) Nucl. Acids Res. 28, 292.
3030
31-
32-
Contribute
33-
----------
34-
35-
This project was started at the Edinburgh Genome Foundry by Zulko and is released on `Github <https://github.com/Edinburgh-Genome-Foundry/codon-usage-tables>`_ under a Public Domain licence (and no warranty whatsoever, please cross-check the codon usage with other sources if you are not sure). Feel free to add other tables if you think of more commonly used species.
36-
37-
Installation
38-
------------
39-
40-
via pip:
41-
42-
.. code:: bash
43-
44-
pip install python_codon_tables
45-
46-
Manual:
47-
48-
.. code:: bash
49-
50-
(sudo) python setup.py install
51-
5231
Usage
5332
-----
5433

@@ -62,18 +41,41 @@ Usage
6241
# LOAD ONE TABLE BY NAME
6342
table = pct.get_codons_table("b_subtilis_1423")
6443
print (table['T']['ACA']) # returns 0.4
65-
print (table['*']['UAA']) # returns 0.61
44+
print (table['*']['TAA']) # returns 0.61
6645
6746
# LOAD ONE TABLE BY TAXID (it will get it from the internet if it is not
6847
# in the builtin tables)
6948
table = pct.get_codons_table(1423)
7049
print (table['T']['ACA']) # returns 0.4
71-
print (table['*']['UAA']) # returns 0.61
50+
print (table['*']['TAA']) # returns 0.61
7251
7352
# LOAD ALL BUIL-IN TABLES AT ONCE
7453
codons_tables = pct.get_all_available_codons_tables()
75-
print (codons_tables['c_elegans_6239']['L']['CUA']) # returns 0.09
54+
print (codons_tables['c_elegans_6239']['L']['CTA']) # returns 0.09
7655
77-
In ``get_codons_table`` you can also provide a "shorthand" notation
56+
- Notice that by default the tables use nucleotide T instead of U. Using
57+
``get_codons_table('e_coli', replace_U_by_T=False)`` will leave Us as Us.
58+
59+
- In ``get_codons_table`` you can also provide a "shorthand" notation
7860
``b_subtilis``, which will be automatically extended to ``b_subtilis_1423`` as
7961
it appears so in the built-in table (use this feature at your own risks!)
62+
63+
Contribute
64+
----------
65+
66+
This project was started at the Edinburgh Genome Foundry by Zulko and is released on `Github <https://github.com/Edinburgh-Genome-Foundry/codon-usage-tables>`_ under a Public Domain licence (and no warranty whatsoever, please cross-check the codon usage with other sources if you are not sure). Feel free to add other tables if you think of more commonly used species.
67+
68+
Installation
69+
------------
70+
71+
via pip:
72+
73+
.. code:: bash
74+
75+
pip install python_codon_tables
76+
77+
Manual:
78+
79+
.. code:: bash
80+
81+
(sudo) python setup.py install
-371 Bytes
Binary file not shown.

python_codon_tables/codon_usage_tables.egg-info/PKG-INFO

Lines changed: 0 additions & 52 deletions
This file was deleted.

python_codon_tables/codon_usage_tables.egg-info/SOURCES.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

python_codon_tables/codon_usage_tables.egg-info/dependency_links.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

python_codon_tables/codon_usage_tables.egg-info/top_level.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

python_codon_tables/python_codon_tables.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@ def table_with_U_replaced_by_T(table):
4242
@lru_cache(maxsize=128)
4343
def get_codons_table(table_name, replace_U_by_T=True):
4444
"""Get data from one of this package's builtin codon usage tables.
45-
46-
Returns a dict {"*": {'UAA': 0.64...}, 'K': {'AAA': 0.76...}, ...}
4745
48-
The table_name argument very flexible on purpose, it can be either an
46+
The ``table_name`` argument very flexible on purpose, it can be either an
4947
integer representing a taxonomic ID (which will be downloaded from
5048
the kazusa database), or a string "12245" representing a TaxID, or a string
5149
"e_coli_316407" referring to a builtin table of python_codon_optimization,
5250
or a short form "e_coli" which will be automatically extended to
5351
"e_coli_316407" (at your own risks).
52+
53+
The ``replace_U_by_T`` argument will replace all codons names from UAA to
54+
TAA etc.
55+
56+
Returns a dict {"*": {'TAA': 0.64...}, 'K': {'AAA': 0.76...}, ...}
5457
"""
5558
if replace_U_by_T:
5659
table = get_codons_table(table_name, replace_U_by_T=False)
@@ -62,10 +65,10 @@ def get_codons_table(table_name, replace_U_by_T=True):
6265
with open(os.path.join(_tables_dir, table_name + '.csv'), 'r') as f:
6366
return csv_string_to_codons_dict(f.read())
6467

65-
def get_all_available_codons_tables():
68+
def get_all_available_codons_tables(replace_U_by_T=True):
6669
"""Get all data from all of this package's builtin codon usage tables."""
6770
return {
68-
table_name: get_codons_table(table_name)
71+
table_name: get_codons_table(table_name, replace_U_by_T=replace_U_by_T)
6972
for table_name in available_codon_tables_names
7073
}
7174

Binary file not shown.

python_codon_tables/tests/test_basics.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def test_basics():
88
# LOAD ONE TABLE BY NAME
99
table = pct.get_codons_table("b_subtilis_1423")
1010
assert table['T']['ACA'] == 0.4
11-
assert table['*']['UAA'] == 0.61
11+
assert table['*']['TAA'] == 0.61
1212

1313
# LOAD ALL TABLES AT ONCE
1414
codon_tables = pct.get_all_available_codons_tables()
15-
assert codon_tables['c_elegans_6239']['L']['CUA'] == 0.09
15+
assert codon_tables['c_elegans_6239']['L']['CTA'] == 0.09
1616

1717
def test_download_codon_table(tmpdir):
1818
table = pct.download_codons_table(taxid=316407)
@@ -23,24 +23,24 @@ def test_download_codon_table(tmpdir):
2323
def test_readme_example():
2424
table = pct.get_codons_table("b_subtilis_1423")
2525
assert table['T']['ACA'] == 0.4
26-
assert table['*']['UAA'] == 0.61
26+
assert table['*']['TAA'] == 0.61
2727

2828
# LOAD ALL TABLES AT ONCE
2929
codons_tables = pct.get_all_available_codons_tables()
30-
assert codons_tables['c_elegans_6239']['L']['CUA'] == 0.09
30+
assert codons_tables['c_elegans_6239']['L']['CTA'] == 0.09
3131

3232
# GET A TABLE DIRECTLY FROM THE INTERNET
3333
table = pct.download_codons_table(taxid=316407)
34-
assert table['*']['UGA'] == 0.29
34+
assert table['*']['TGA'] == 0.29
3535

3636
def test_readme_example():
3737
table = pct.get_codons_table("b_subtilis_1423")
3838
assert table['T']['ACA'] == 0.4
39-
assert table['*']['UAA'] == 0.61
39+
assert table['*']['TAA'] == 0.61
4040

4141
# LOAD ALL TABLES AT ONCE
4242
codons_tables = pct.get_all_available_codons_tables()
43-
assert codons_tables['c_elegans_6239']['L']['CUA'] == 0.09
43+
assert codons_tables['c_elegans_6239']['L']['CTA'] == 0.09
4444

4545
# GET A TABLE DIRECTLY FROM THE INTERNET
4646
table = pct.download_codons_table(taxid=316407)
@@ -50,4 +50,8 @@ def test_get_codons_table():
5050
for table_name in (1423, "1423", "b_subtilis", "b_subtilis_1423"):
5151
table = pct.get_codons_table(table_name)
5252
assert table['T']['ACA'] == 0.4
53-
assert table['*']['UAA'] == 0.61
53+
assert table['*']['TAA'] == 0.61
54+
55+
def test_replace_U_by_T():
56+
table = pct.get_codons_table("b_subtilis_1423", replace_U_by_T=False)
57+
assert table['*']['UAA'] == 0.61

0 commit comments

Comments
 (0)