benjamin-lee / codonadaptationindex Goto Github PK
View Code? Open in Web Editor NEWPython Implementation of Codon Adaption Index
Home Page: https://cai.readthedocs.io
License: MIT License
Python Implementation of Codon Adaption Index
Home Page: https://cai.readthedocs.io
License: MIT License
Hi Ben,
I just thought I’d let you know about an issue with installing I found. I’ve hacked my way around it, but others may encounter it.
Any variation of pip3 install CAI
greeted me with:
Processing /home/wms_joe/repos/CodonAdaptationIndex
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-441r21d4/setup.py", line 7, in <module>
long_description = f.read()
File "/home/wms_joe/bin/miniconda3/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2445: ordinal not in range(128)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-441r21d4/
Searching online suggests its a locale encoding issue, however I tried to set several locale environmental variables, as corresponds to other issues I’ve seen for this ascii error:
export LC_ALL=C
export LC_CTYPE=en_US.UTF-8
export LANG=en_US.UTF-8
None of which worked.
The issue appears to be with the README.rst
, so I was able to finally install it inside a cloned repo with pip3 install .
after emptying the contents of the file. I’m still not sure exactly where the issue arises though, as at a glance, I couldn’t see an unusual character anywhere.
Subsequently discovered that, contrary to the internet’s advice, the encoding should be en_US.utf8
not UTF-8
. Though I suspect that may be due to this being installed on an older ubuntu box (14.04!).
Fortunately, click
outputs a useful error message, and setting LC_ALL
to en_US.utf8
allowed the program to run correctly (I haven’t checked if that is also the case for the installation as it’s already on the system now).
Traceback (most recent call last):
File "/home/wms_joe/bin/miniconda3/bin/CAI", line 11, in <module>
sys.exit(cli())
File "/home/wms_joe/bin/miniconda3/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/wms_joe/bin/miniconda3/lib/python3.6/site-packages/click/core.py", line 696, in main
_verify_python3_env()
File "/home/wms_joe/bin/miniconda3/lib/python3.6/site-packages/click/_unicodefun.py", line 124, in _verify_python3_env
' mitigation steps.' + extra
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/en/7.x/python3/ for mitigation steps.
This system lists a couple of UTF-8 supporting locales that
you can pick from. The following suitable locales were
discovered: en_US.utf8
$ export LC_ALL=en_US.utf8
$ CAI -h
Usage: CAI [OPTIONS]
Try "CAI --help" for help.
Error: no such option: -h
I don’t know if you want to consider this resolved or if this is something worth patching/including in the install instructions?!
I made a conda package of version v1.0.3, available here.
Install by:
conda install -c bjornfjohansson cai
In the README, it would be good to provide more guidance, e.g. "open a pull request to contribute" (With a pointer to github documentation) and "use the issue tracker (link) to file an issue."
I am testing CAI package following your instructions and I got a bug when processing small sequences. My sequence is:
>testseq
ATGAAATTAATATTGAAACTCGTGGAACGGAAAAAACTGATCAAGGAGTTAAAAGAAGATATTGAAGTAATTTAA
Then, when I execute the program:
>>> reference = [seq.seq for seq in SeqIO.parse("../database/annotation/1036673.PRJNA67335/1036673.PRJNA67335.ffn", "fasta")]
>>> CAI(sequence, reference=reference)
I receive this message:
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/CAI/CAI.py", line 220, in CAI
weights = relative_adaptiveness(sequences=reference, genetic_code=genetic_code)
File "/usr/local/lib/python3.7/dist-packages/CAI/CAI.py", line 149, in relative_adaptiveness
RSCUs = RSCU(sequences, genetic_code=genetic_code)
File "/usr/local/lib/python3.7/dist-packages/CAI/CAI.py", line 75, in RSCU
raise ValueError("Input sequence not divisible by three")
ValueError: Input sequence not divisible by three
The problem is, this is a coding sequence that we work for long time now and it is divisible in codons (presents even the start and stop codon there). So, I do not know what is misinterpreted by the package. I look forward to hearing from you.
It would be great to provide some full examples that let a new user immediately run CAI on some real data. For my JOSS review I'm going to have to hunt down the right files before I review the functionality!
Just like it sounds. It'd be great to see how to use the RSCU param in the docs. In particular how to integrate it with the value from python_codon_tables.get_codons_table()
.
Most of the examples are using a reference genome and I get key errors when I try:
RSCU = python_codon_tables.get_codons_table("h_sapiens")
initial_grade = CAI.CAI(initial_seq, RSCUs=RSCU)
Hi, I made a notebook confirming that CAI gives the expected results from the old data in the original papers.
Perhaps you would consider including it? Is so, I can do a pull request.
Dependabot can't evaluate your Python dependency files.
As a result, Dependabot couldn't check whether any of your dependencies are out-of-date.
The error Dependabot encountered was:
InstallationError("Invalid requirement: 'MIT License'\n",)
You can mention @dependabot in the comments below to contact the Dependabot team.
I think it is the 2to3 option in setup.py.
Is 2to3 still needed?
Collecting CAI Using cached CAI-1.0.3.tar.gz (6.0 kB) ERROR: Command errored out with exit status 1: command: /home/bjorn/anaconda3/envs/new39/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-y9phjkp9/cai_8c869096cf864cb8934fa27a731d3393/setup.py'"'"'; __file__='"'"'/tmp/pip-install-y9phjkp9/cai_8c869096cf864cb8934fa27a731d3393/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-52f8wm2g cwd: /tmp/pip-install-y9phjkp9/cai_8c869096cf864cb8934fa27a731d3393/ Complete output (1 lines): error in CAI setup command: use_2to3 is invalid.
from CAI import CAI
from Bio import SeqIO # to parse FASTA files
reference = [seq.seq for seq in SeqIO.parse("/Users/rthapa/Downloads/Sbicolor_454_v3.1.1.protein.fa", "fasta")]
sequence = SeqIO.read("/Users/rthapa/Downloads/Sbicolor_454_v3.0.1.fa", "fasta")
CAI(sequence, reference=reference)
I am checking RSCU() method and it seems to me that small performance improvement is possible in codon counting. It should be faster to once call upper() method for a sequence than for each of it's codons separately.
Lines ~80, adding line like sequences = [s.upper() for s in sequences]
can improve perf.
Simple check shows ~30% improvements:
python3 -m timeit 'x = ("a"*300000); [x[i: i+3].upper() for i in range(0, len(x), 3)]'
10 loops, best of 3: 21.3 msec per loop
python3 -m timeit 'x = ("a"*300000).upper(); [x[i: i+3] for i in range(0, len(x), 3)]'
100 loops, best of 3: 14.5 msec per loop
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.