在python肌肉排列 [英] Muscle alignment in python

查看:855
本文介绍了在python肌肉排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有打印肌肉对准我的输出在python的一个问题。我的code是:

I have a problem with printing my output from muscle aligning in python. My code is:

from Bio.Align.Applications import MuscleCommandline
from StringIO import StringIO
from Bio import AlignIO

def align_v1 (Fasta): 
    muscle_cline = MuscleCommandline(input="hiv_protease_sequences_w_wt.fasta")
    stdout, stderr = muscle_cline()
    MultipleSeqAlignment = AlignIO.read(StringIO(stdout), "fasta") 
    print MultipleSeqAlignment 

任何帮助吗?

Any help?

推荐答案

这将是很好知道你收到了什么错误,但下面应该解决您的问题:

It would be nice to know what error you received, but the following should solve your problem:

from Bio.Align.Applications import MuscleCommandline
from StringIO import StringIO
from Bio import AlignIO

muscle_exe = r"C:\muscle3.8.31_i86win32.exe" #specify the location of your muscle exe file

input_sequences = "hiv_protease_sequences_w_wt.fasta"
output_alignment = "output_alignment.fasta"

def align_v1 (Fasta): 
    muscle_cline = MuscleCommandline(muscle_exe, input=Fasta, out=output_alignment)
    stdout, stderr = muscle_cline()
    MultipleSeqAlignment = AlignIO.read(output_alignment, "fasta") 
    print MultipleSeqAlignment

align_v1(input_sequences)

在我来说,我收到一个ValueError错误:

In my case I received a ValueError:

>>> AlignIO.read(StringIO(stdout), "fasta") 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\WinPython-64bit-3.3.2.3\python-3.3.2.amd64\lib\site-packages\Bio\AlignIO\__init__.py", line 427, in read
    raise ValueError("No records found in handle")
ValueError: No records found in handle

这可避免通过保存,输出和AlignIO.read重新开放。

This could be avoided by saving the output and reopening with AlignIO.read.

我也收到了可避免通过指定的肌肉exe文件的位置FileNotFoundError。例如:

I also received a FileNotFoundError that could be avoided by specifying the location of the muscle exe file. eg:

muscle_exe = r"C:\muscle3.8.31_i86win32.exe" 

有此的说明示于帮助(MuscleCommandline),但这不是目前在Biopython教程页

The instructions for this are shown in help(MuscleCommandline), but this is not currently in the Biopython tutorial page.

最后,我假设你想用不同的输入序列运行​​的命令,所以我改性的函数的格式函数名(INPUT_FILE)。

Finally, I am assuming you want to run the command using different input sequences, so I modifed the function to the format "function_name(input_file)."

我用蟒蛇3.3。但愿code以上是对于Python 2.x的在你原来的职位。对于Python 3.x中,从StringIO的进口StringIO的从IO导入StringIO的,当然还有打印MultipleSeqAlignment更改为打印(MultipleSeqAlignment)。

I used python 3.3. Hopefully the code above is for python 2.x as in your original post. For python 3.x, change "from StringIO import StringIO" to "from io import StringIO" and of course "print MultipleSeqAlignment" to "print(MultipleSeqAlignment)".

这篇关于在python肌肉排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆