Search code examples
pythonalignmentbioinformaticsbiopython

Muscle Multiple Sequence Alignment with Biopython?


I just learned to use python (and Biopython) so this question may bespeak my inexperience.

In order to carry out MSA of sequences in a file (FileA.fasta), I use the following code:

from Bio.Align.Applications import MuscleCommandline
inp = 'FileA.fasta'
outp = 'FileB.fasta'
cline = MuscleCommandline(input=inp, out=outp)
cline()

I get the following error:

ApplicationError
... 
 Non-zero return code 127 from 'muscle -in FileA.fasta -out FileB.fasta', message '/bin/sh: muscle: command not found'

I know that this has something to do with the executable not being in my working PATH. The Biopython tutorial suggests that I update the PATH to include the location of Muscle Tools and it gives an example of this for Windows, but I don't know how to do this for MAC.

Please help.

Thank you.


Solution

  • First make sure you know where you installed muscle. If, for example, you installed muscle in:

    /usr/bin/muscle3.8.31_i86darwin64
    

    then you edit /etc/paths with:

    $ sudo vi /etc/paths
    

    Each entry is separated by line breaks:

    /usr/local/bin
    /bin
    /usr/sbin
    /sbin
    

    Add the appropriate path (in this example /usr/bin) to the list. Save with wq!

    Now, make sure the muscle is on your path. Try to run

    muscle -in FileA.fasta -out FileB.fasta
    

    If that works, the BioPython code should work as well.