[Biopython] alignment in biopython using `clustalW

Peter Cock p.j.a.cock at googlemail.com
Thu Aug 28 23:28:47 UTC 2014


On Fri, Aug 29, 2014 at 8:06 AM, Jakub Stanislaw Nowak
<jakub.nowak at ed.ac.uk> wrote:
> Hello,
>
> I am trying to run alignment using ClustalW in python.
>
> I have used this code to compile
>
> cline = ClustalwCommandline("clustalw2", infile="test.fasta")
> print(cline)
> stdout, stderr = cline()
> align = AlignIO.read("test.aln", "clustal")
> print(align)
>
>
> But it is generating file. I think I have some problem with setting a proper
> pathway to  clustal.
>
>
> This is the error:
>
> clustalw2 -infile=test.fasta
> Traceback (most recent call last):
>   File "/Users/user/Google Drive/Bioinformatics/smallRNAseq/Python U
> densities/trial4old.py", line 95, in <module>
>     stdout, stderr = cline()
>   File
> "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Bio/Application/__init__.py",
> line 513, in __call__
>     stdout_str, stderr_str)
> Bio.Application.ApplicationError: Non-zero return code 127 from 'clustalw2
> -infile=test.fasta', message '/bin/sh: clustalw2: command not found'
>
>
>
> Can you suggest some solution?

What happens at the command line (outside Python)
if you run these command?

$ clustalw2 -infile=test.fasta

$ which clustalw2

If that fails, it means clustalw2 is not installed on your $PATH.
How was clustalw2 installed?

If you have clustalw2 somewhere like this:
/Users/jakub/downloads/clustalw2.1/bin/clustalw2

Then the command would become:

/Users/jakub/downloads/clustalw2.1/bin/clustalw2 -infile=test.fasta

The Python code would become:

cline = ClustalwCommandline("/Users/jakub/downloads/clustalw2.1/bin/clustalw2",
infile="test.fasta")

Regards,

Peter


More information about the Biopython mailing list