Trouble Calling Biopython Sequtils Six_Frame_Translations
4
0
Entering edit mode
11.6 years ago

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

python biopython • 3.4k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode
11.6 years ago
Peter 6.0k

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

ADD COMMENT
0
Entering edit mode
11.6 years ago

Use Python 2.7 for BioPython - the software is not fully supported for the Python 3 branch.

ADD COMMENT
0
Entering edit mode

Is there a method to 'revert' to python 2.7 from 3.23? Will I lose any functionality? What about script syntax?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Perhaps it would be easier to find another module (or even another external program such as EMBOSS) to translate my sequences?

ADD REPLY
1
Entering edit mode
ADD REPLY
0
Entering edit mode

This isn't actually a Python 3 issue - the same problem happens on Python 2 as well :(

ADD REPLY
0
Entering edit mode
11.6 years ago

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??

ADD COMMENT

Login before adding your answer.

Traffic: 2845 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6