Question: MafftCommandline error, doesn't recognize mafft as an internal or external command
gravatar for erikras1223
4.6 years ago by
United States
erikras122310 wrote:

Hello I am new to python and biopython, but I thought I had the code just about right but I am getting this error " File "C:\Python27\lib\site-packages\Bio\Application\", line 517, in __call__stdout_str, stderr_str)
Bio.Application.ApplicationError: Non-zero return code 1 from 'mafft NA.fa', message "'mafft' is not recognized as an internal or external command,"

The line it crashes at is stdout,stderr = mafft_cline(), I don't really understand what it means by "mafft" is not recognized as an internal or external command, but I just want to do an alignment on the file NA.fa. I would very grateful for some help on why it get this exceptions.

the file looks like this:



the code looks like this:


from Bio.Align.Applications import MafftCommandline

for filename in glob("*.fa"):
    with open(filename) as f:
        output = str(filename)
        output += "-aligned.fa"
        in_file = str(filename)
        mafft_cline = MafftCommandline(input= in_file)
        print mafft_cline
        stdout, stderr = mafft_cline()
        with open(output, "-w") as handle:


mafft error alignment • 2.5k views
ADD COMMENTlink written 4.6 years ago by erikras122310

Do you have MAFFT installed?

ADD REPLYlink written 4.6 years ago by h.mon30k

Ok so i've now download MAFFT ran cygwin to extract it, I am just having a mental gap on how to use the MafftCommandLine recognize that mafft is installed. I know I will have to give it a path but I used cygwin to extract the tar file of mafft and it seems to of installed it in some location I can't find it gives me like a psuedo path if that makes any sense

ADD REPLYlink modified 4.6 years ago • written 4.6 years ago by erikras122310

Did you compile MAFFT, or just extracted it?

ADD REPLYlink modified 7 months ago by RamRS27k • written 4.6 years ago by h.mon30k

I downloaded this file mafft-7.266-mingwxx.tar and through cygwin used this command tar xfv mafft-7.266-mingwxx.tar -C /. So just extracted I am not sure how to compile it. From that point I could run mafft through cygwins shell but not through my python script. I was under the impression that if installed bioPython and its dependencies it would have the applications like mafft, already compiled. Is that not correct?

ADD REPLYlink modified 7 months ago by RamRS27k • written 4.6 years ago by erikras122310

No, it is a bit more complex than that, you probably have to set up the PATH environment variable. You have a problem, in which very few people is using Cygwin to work with bioinformatics, so few people will be able to help - most people use linux or macosx.

Anyway, it seems you have some reading to do, you could start here.

ADD REPLYlink written 4.6 years ago by h.mon30k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1925 users visited in the last hour