This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython Emboss Needle gives no output file

I'm learning Emboss Needle from biopython to align two sequences. When I type in the following comments(used as an example from Biopython cookbook):

from Bio.Emboss.Applications import NeedleCommandline
needle_cline = NeedleCommandline(asequence="alpha.faa", bsequence="beta.faa", gapopen=10, gapextend=0.5, outfile="needle.txt")
print(needle_cline)

It returns: needle -outfile=needle.txt -asequence=alpha.faa -bsequence=beta.faa -gapopen=10 -gapextend=0.5

However, no output file named "needle.txt" is generated. All input files are present. No errors msg appear in the process. Anyone knows what went wrong? Thanks!

alignment

2 answers

You just created a needle command line object without actually running the program :)

To run the command, type:

stdout, stderr = needle_cline()
print(stdout + stderr)

The output file needle.txt should be right there for you. For more information, read the whole 6.4.5. section (EMBOSS needle and water) in the BioPython Tutorial and Cookbook.

Thank you! However, when I type in

stdout, stderr = needle_cline()

It returns:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/Application/__init__.py", line 516, in __call__ stdout_str, stderr_str) Bio.Application.ApplicationError: Non-zero return code 127 from 'needle -outfile=needle.txt -asequence=alpha.faa -bsequence=beta.faa -gapopen=10 -gapextend=0.5', message '/bin/sh: needle: command not found'

Is there something wrong with PATH?

Probably. It can't find needle in default $PATH.

Keep reading the cookbook, you should execute this line.

Log in to answer this question.