Muscle and clustal alignment using biopython
1
0
Entering edit mode
4.3 years ago
jerald • 0

HI all,

I'm trying to learn biopython and am learning from the tutorial book, however when i try to do muscle or clustal alignment, i keep getting errors. How can i get past this? Is it because of the version of my windows is not compatible? i'm using 64bit.

hoping you could help, Thanks~

biopython clustal muscle • 3.6k views
ADD COMMENT
2
Entering edit mode
4.3 years ago

What is the error you're getting? There's a good chance that you don't have MUSCLE or Clustal installed on your computer, or Biopython cannot find the executables.

You can tell Biopython where to find these executables, from the help:

  >>> from Bio.Align.Applications import MuscleCommandline
  >>> muscle_exe = r"C:\Program Files\Aligments\muscle3.8.31_i86win32.exe"
  >>> in_file = r"C:\My Documents\unaligned.fasta"
  >>> out_file = r"C:\My Documents\aligned.fasta"
  >>> muscle_cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)
  >>> print(muscle_cline)
  "C:\Program Files\Aligments\muscle3.8.31_i86win32.exe" -in "C:\My Documents\unaligned.fasta" -out "C:\My Documents\aligned.fasta"

It works the same for clustalw:

  >>> clustalw_cline = ClustalwCommandline(r"C:\Program Files\Aligments\clustalw2", infile=in_file)

Of course you'd have to adjust the path.

ADD COMMENT
0
Entering edit mode

Hi, thank you for your response, I get this

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\Bio\AlignIO\__init__.py", line 425, in read
    first = next(iterator)
  File "C:\Python27\lib\site-packages\Bio\AlignIO\__init__.py", line 372, in parse
    for a in i:
  File "C:\Python27\lib\site-packages\Bio\AlignIO\ClustalIO.py", line 109, in __next__
    ", ".join(known_headers)))
ValueError: >gi|6273291|gb|AF191665.1|AF191665 is not a known CLUSTAL header: CLUSTAL, PROBCONS, MUSCLE, MSAPROBS, Kalign

If I don't have the executables, do you know where can i get them? and which path should I install?

ADD REPLY
1
Entering edit mode

I added markup to your post for increased readability. You can do this by selecting the text and clicking the 101010 button. When you compose or edit a post that button is in your toolbar, see image below:

101010 Button

ADD REPLY
0
Entering edit mode

Thank you so much for that, next time i post something similar I'll be sure to use it

ADD REPLY
1
Entering edit mode

I see! The code you're trying to run expects output from Clsutal, but you're trying to give it a FASTA file. You have to align the sequences in the FASTA file using Clustal first to get the format your code wants.

ADD REPLY
0
Entering edit mode

Ah I see, but how do I make alignments using the fasta file? Thank you so much~ when try to input I get this

from Bio.Align.Applications import ClustalwCommandline cline = ClustalwCommandline("clustalw2", infile="opuntia.fasta") print(cline) clustalw2 -infile=opuntia.fasta import os from Bio.Align.Applications import ClustalwCommandline clustalw_exe = r"C:\Program Files\new clustal\clustalw2.exe" clustalw_cline = ClustalwCommandline(clustalw_exe, infile="opuntia.fasta") assert os.path.isfile(clustalw_exe), "Clustal W executable missing" Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError: Clustal W executable missing

I get this... sorry, I'm a real newbie at biopython

ADD REPLY
1
Entering edit mode

When you run the code like that, Windows assumes that your 'clustalw2' executable is in the current folder you're running it in.

You'll have to download clustalw2 (if you haven't done so already) and use the full path to make this error message go away:

ClustalwCommandline("C:\Downloads\clustalw2", infile="opuntia.fasta")

replace the C:\Downloads path with wherever you downloaded clustalw2 to

ADD REPLY
0
Entering edit mode

I see, then i need an executable file for clustal and muscle in the same folder as my fasta file? Do you know where I can get it? and Thank you again~

ADD REPLY
1
Entering edit mode

You can get them from google :)

Their path doesn't matter as long as you explicitly set both, they can be in different folders.

ADD REPLY
0
Entering edit mode

Got it~ Thanks so much~ :) I'll try getting first the executables and run it.

ADD REPLY

Login before adding your answer.

Traffic: 1970 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