-1

I'm trying to align with Muscle some example sequences from opuntia.fasta (from BioPython manual)

from Bio.Align.Applications import MuscleCommandline
in_file = "C:/Try/opuntia.fasta"
out_file = "C:/Try/aligned.fasta"
muscle_exe = "C:/Program Files/Aligments/muscle3.8.31_i86win32.exe"
cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)
stdout, stderr = cline(in_file)
from StringIO import StringIO
from Bio import AlignIO
align = AlignIO.read(StringIO(stdout), "fasta")
print(align)

I won't get anything in C:/Try/.

Error message:

Traceback (most recent call last):
  File "C:/Try/try.py", line 6, in <module>
    stdout, stderr = cline()
  File "C:\Python27\lib\site-packages\Bio\Application\__init__.py", line 517, in __call__
    stdout_str, stderr_str)
ApplicationError: Non-zero return code 1 from '"C:\\Program Files\\Aligments\\muscle3.8.31_i86win32.exe" -in C:/Try/opuntia.fasta -out C:/Try/aligned.fasta' message '\x91\xa8\xe1\xe2\xa5\xac\xa5 \xad\xa5 \xe3\xa4\xa0\xa5\xe2\xe1\xef \xad\xa0\xa9\xe2\xa8 \xe3\xaa\xa0\xa7\xa0\xad\xad\xeb\xa9 \xaf\xe3\xe2\xec.'

What am I doing wrong? Python 2.7.10

blubberdiblub
  • 4,085
  • 1
  • 28
  • 30
lizaveta
  • 353
  • 1
  • 13
  • 3
    What happens when you type '"C:\\Program Files\\Aligments\\muscle3.8.31_i86win32.exe" -in C:/Try/opuntia.fasta -out C:/Try/aligned.fasta' on the command line? If that also exits with a non-zero return code, then you have a problem with Muscle, not Python. – heathobrien May 02 '17 at 13:19

2 Answers2

0

BioPython's MuscleCommandline is just a wrapper for the Muscle executable. You would need to download it from here http://www.drive5.com/muscle/downloads.htm and install it. In your case (Windows OS) you would need to copy the exe to some location and reference it in your variable muscle_exe.

Maximilian Peters
  • 30,348
  • 12
  • 86
  • 99
0

I found out what was the problem. First, paths to all files should be relative and second, I replaced

align = AlignIO.read(StringIO(stdout), "fasta")

with

align = AlignIO.read(out_file, "fasta")

and it worked!

lizaveta
  • 353
  • 1
  • 13