pythonbiopythonsequence-alignment

MuscleCommandline not working in Biopython


I need to integrate my python script with the muscle tool for multiple sequence alignment. I followed the tutorial on Biopython, here there is my code:

from Bio.Align.Applications import MuscleCommandline
muscle_exe = "muscle.exe"
in_file = "small.fasta"
out_file = "aligned.fasta"
muscle_cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)

print(muscle_cline)

I am running it in correct folder with the renamed muscle.exe file. However, python does not output anything except the command and the file aligned.fasta is not created. I saw the old questions, but it seems that nobody has ever had this problem. Muscle is working fine in the normal command line. Thank you.


Solution

  • The manual is a bit confusing in my opinion. The print does not start muscle but just prints the command which would be executed. You could run muscle either by calling

    stdout, stderr = muscle_cline()
    

    or without BioPython

    import subprocess
    muscle_result = subprocess.check_output([muscle_exe, "-in", in_file, "-out", out_file])