This is a test version of Biostars. For the public version, visit https://www.biostars.org.
MafftCommandline error, doesn't recognize mafft as an internal or external command

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\__init__.py", 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:

>NA
MNPNQKIITIGSVCMTIGMANLILQIGNIISIWISHSIQLGNQNQIETCNQSVITYENNTWVNQTYVNISNTNFAAGQSVVPVKLAGNSSLCPVSGWAIYSKDNSIRIGSKGDVFVIREPFISCSPLECRTFFLTQGALLNDKHSNGTIKDRSPYRTLMSCPIGEVPSPYNSRFESVAWSASACHDGINWLTIGISGPDNGAVAVLKYNGIITDTIKSWRNNILRTQESECACVNGSCFTVMTDGPSDGQASYKIFRIEKGKIVKSVEMNAPNYHYEECSCYPDSSEITCVCRDNWHGSNRPWVSFNQNLEYQIGYICSGIFGDNPRPNDKTGSCGPVSSNGANGVKGFSFKYGNGVWIGRTKSISSRNGFEMIWDPNGWTGTDNNFSIKQDIVGINEWSGYSGSFVQHPELTGLDCIRPCFWVELIRGRPKENTIWTSGSSISFCGVNSGTVGWSWPDGAELPFTIDK
>NA
MNPNQKIITIGSVCMTIGMANLILQIGNIISIWISHSIQLGNQNQIETCNQSVITYENNTWVNQTYVNISNTNFAAGQSMVSVKLTGNSSLCPVSGWAIYSKDNSVRIGSKGDVFVIREPFISCSPLECRTFFLTQGALLNDKHSNGTIKDRSPYRTLMSCPIGEVPSPYNSRFESVAWSASACHDGINWLTIGISGPDNGAVAVLKYNGIITDTIKSWRNNILRTQESECACVNGSCFTVMTDGPSNGQASYKIFRIEKGKIVKSVEMNAPNYHYEECSCYPDSSEITCVCRDNWHGSNRPWVSFNQNLEYQIGYICSGIFGDNPRPNDKTGSCGPVSSNGANGVKGFSFKYGNGVWIGRTKSISSRNGFEMIWDPNGWTGTDNNFSIKQDIVGINEWSGYSGSFVQHPELTGLDCIRPCFWVELIRGRPKENTIWTSGSSISFCGVNSDTVGWSWPDGAELPFTIDK
>NA
MNPNQKIITIGSVCITIGMANLILQIGNIISIWVSHSIQIGNQSQIETCNQSVITYENNTWVNQTYVNISNTNFAAGQSVVSVKLAGNSSLCPVSGWAIYSKDNSVRIGSKGDVFVIREPFISCSPLECRTFFLTQGALLNDKHSNGTIKDRSPYRTLMSCPIGEVPSPYNSRFESVAWSASACHDGINWLTIGISGPDSGAVAVLKYNGIITDTIKSWRNNILRTQESECACVNGSCFTIMTDGPSDGQASYKIFRIEKGKIVKSVEMNAPNYHYEECSCYPDSSEITCVCRDNWHGSNRPWVSFNQNLEYQIGYICSGVFGDNPRPNDKTGSCGPVSSNGANGVKGFSFKYGNGVWIGRTKSISSRKGFEMIWDPNGWTGTDNKFSIKQDVVGINEWSGYSGSFVQHPELTGLDCIRPCFWVELIRGRPEENTIWTSGSSISFCGVNSDTVGWSWPDGAELPFTIDK

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:
            handle.write(stdout)
mafft error alignment

Do you have MAFFT installed?

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

Did you compile MAFFT, or just extracted it?

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?

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.

0 answers

No answers yet.

Log in to answer this question.