I'm trying to run needle using Biopython's NeedleCommandline. The two input files are tempfile.NamedTemporaryFiles.
 cline = NeedleCommandline(asequence=gene_fasta.name, 
                           bsequence=chain_fasta.name,
                           gapopen=10,
                           gapextend=1,
                           stdout=True)
 stdout, stderr = cline()
This returns "Bio.Application.ApplicationError: Command 'needle -stdout -asequence=/var/folders/zm/jvdqjg5j3kg67_pxlsjc84c40000gn/T/tmpQXYVkP -bsequence=/var/folders/zm/jvdqjg5j3kg67_pxlsjc84c40000gn/T/tmpcVFncj -gapopen=10 -gapextend=1' returned non-zero exit status 1, 'Needleman-Wunsch global alignment of two sequences'"
I tried running the same command by hand (after setting the NamedTemporaryFile(delete=False) in both files) and it runs just fine. I also tried using an output file (with outfile="xxx.needle" in NeedleCommandline) but it still doesn't work.
I also verified the return code when running it manually by 'echo $#' and it is 0.
Try to get the return code of the last command by '$?' and not '$#'. The latter is a string length on an empty string, which is always 0.
Argh, thanks for pointing that out
Could you double check the file handles for the A and B sequences have been closed before calling needle?