alignment using needleman wunsch in biopython
1
0
Entering edit mode
9.6 years ago

I want to align two sequnces in bipython using needleman wunsch algorithm

file1.faa:

>seq_1
gagtcccagctgtgcctgactaaccgtgtttctcttgtatctaggagtgctcccaccccagcccgttgctgcccagctgtttaattgagttgtcatatgttaataacggtatattggaacactgtataacaccaacacactcgagtctttcaagactgcagataagaagctccttttggaacaagcagcaaatgaggttagctg

file2.faa:

>seq_2
GAGTCCCAGCTGTGCCTGACTAACCGTGTTTCTCTTGTATCTAGGAGTGCTCCCACCCCAGCCCGTTGCTGCCCAGCTGTTTAATTGAGTTGTCATATGTTAATAACGGTATTGGAACACTGTATAACACCAACACACTCGAGTCTTTCAAGACTGCAGATAAGAAGCTCCTTTTGGAACAAGCAGCAAATGAGGTTAGCTGAGATCGGAAGAGCACACGTCTGAACTCCAGTCACTAGCGTTCTCATCT

I have tried

from Bio.Emboss.Applications import NeedleCommandline
from Bio import AlignIO

needle_cline = NeedleCommandline(asequence="file1.faa", bsequence="file2.faa",gapopen=10, gapextend=0.5, outfile="needle.txt")

But the output file needle.txt does not get written. Can you help?

alignment • 4.7k views
ADD COMMENT
1
Entering edit mode
9.6 years ago
utzermel ▴ 120

It seems you only created the wrapper object for the function call. Assuming you have the EMBOSS toolkit installed, this means you still have to call the actual function to make Biopython execute the command. So after creating the wrapper object like this:

needle_cline = NeedleCommandline(asequence="file1.faa", bsequence="file2.faa",gapopen=10, gapextend=0.5, outfile="needle.txt")

you need to actually execute the function like this:

stdout, stderr = needle_cline()

This will create the output file and save any output of the command to the stderr and stdout streams to the respective variables.

ADD COMMENT
0
Entering edit mode

I did the above but I get an error

Bio.Application.ApplicationError: Non-zero return code 127 from 'needle -outfile=needle.txt -asequence=file1.faa -bsequence=file2.faa -gapopen=10 -gapextend=0.5', message '/bin/sh: needle: command not found'

I have installed emboss, so I guess it is a path problem. Can you suggest a fix?

ADD REPLY
0
Entering edit mode

If you are using a Linux operating system, you can append the EMBOSS executables to your path by creating a file entitled EMBOSS.sh (name doesn't matter, but it has to be .sh) in /etc/profile.d/

Make the contents of the file the following:

PATH=$PATH:/path/to/your/EMBOSS/executables
export PATH

Then save the file and restart the terminal you are using python from. For other operating systems I unfortunately don't know how to append things to the PATH, but is should be easy to find out by a simple google search.

ADD REPLY

Login before adding your answer.

Traffic: 1810 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6