Is there a method to 'revert' to python 2.7 from 3.23? Will I lose any functionality? What about script syntax?
Hi, when executing the following code:
from Bio.SeqUtils import six_frame_translations
blah = six_frame_translations("ATCGATCGATCG")
print(blah)
I get the following error:
File "C:\Python32\lib\site-packages\Bio\SeqUtils\__init__.py", line 263, in six_frame_translations
frames[-(i+1)] = reverse(translate(anti[i:], genetic_code))
NameError: global name 'reverse' is not defined
I am using Python 3.23, Biopython 1.59
Any suggestions? Thanks,
Charles
4 answers
This isn't simply a Python 3 problem, just a bug - we removed the 'reverse' function but didn't notice the sixframetranslation function was still using it. Fix here: https://github.com/biopython/biopython/commit/d2ed4f2254938517ccd7843ce8db810d6fe91ab9
That then revealed a more subtle integer vs float problem under Python 3, fix here: https://github.com/biopython/biopython/commit/acf0b9a80718ba9c39f8deb9a23073e98f7fe3e4
P.S. Duplicate question here: http://stackoverflow.com/questions/12165791/trouble-calling-biopython-sequtils-six-frame-translations
Use Python 2.7 for BioPython - the software is not fully supported for the Python 3 branch.
you will not lose any functionality nor will it overwrite anything, just install python 2.7 and once you do make sure to invoke the right version of python when you use it
Perhaps it would be easier to find another module (or even another external program such as EMBOSS) to translate my sequences?
Emboss has sixpack for that: http://emboss.sourceforge.net/apps/cvs/emboss/apps/sixpack.html
This isn't actually a Python 3 issue - the same problem happens on Python 2 as well :(
Thanks for helping me with that issue! Of course, here's another one:
The output format of sixframetranslations is not very helpful for what I'm doing; the output format currently is a "rolling" translation, if you will, and I need them in a "fasta-formatted" orientation. I would like the output format as follows:
>Seq1_Frame_-1
LMNOP
>Seq1_Frame_-2
NOPQR
>Seq1_Frame_-3
OPQRS
....
>Seq2_Frame_-1
ABCDE
>Seq2_Frame_-2
BCDEF
etc. Any ideas??
Log in to answer this question.
the reverse function is broken in Python 3.X, BioPython has a reverse_complement function (http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc23) and the translation function (http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc25) so you can easily built a function to call all six frames and produce the respective translations.