2012-08-28 17 views
0

麻煩執行以下代碼時調用Biopython SeqUtils six_frame_translations

from Bio.SeqUtils import six_frame_translations 

blah = six_frame_translations("ATCGATCGATCG") 
print(blah) 

我得到以下錯誤:

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 

我使用Python 3.23,Biopython 1.59

有什麼建議?謝謝,

Charles

+1

重複的問題在這裏:http://www.biostars.org/post/show/51976/trouble-calling-biopython-sequtils-six_frame_translations/ – peterjc

回答

1

這是一個錯誤。在2011年8月11日之前,SeqUtils模塊具有功能reverse。它在版本1.54和removed in 1.58中被棄用。

從文件DEPRECATED

Function 'reverse' in Bio.SeqUtils was deprecated in Release 1.54, and removed in Release 1.58. Instead just use the string's slice method with a step of minus one.

因此,它看起來他們只是沒有進行這種轉換在six_frame_translations()。 您可以向OBF Redmine網站提交錯誤報告,或自行修補並向GitHub上的Biopython repository提交拉取請求。

如果你感覺特別慷慨,你可以考慮編寫一個單元測試來自動檢測這個函數的失敗 - 它會幫助像你這樣的未來用戶。 =)

+1

現在修復,https://github.com/biopython/biopython/commit/d2ed4f2254938517ccd7843ce8db810d6fe91ab9 - 如果您需要通過編輯C:\ Python32 \ lib \ site-packages \ Bio \ SeqUtils \ __ init__.py(或從源重新安裝Biopython)來緊急使用此更改,請在本地應用相同的更改。 – peterjc

+1

如果在Python 3上,您還需要https://github.com/biopython/biopython/commit/acf0b9a80718ba9c39f8deb9a23073e98f7fe3e4 – peterjc