Question: Muscle and clustal alignment using biopython
0
gravatar for jerald
2.8 years ago by
jerald0
South Korea/Daegu/Kyungpook National University
jerald0 wrote:

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~

muscle biopython clustal • 2.1k views
ADD COMMENTlink modified 2.8 years ago by Philipp Bayer6.6k • written 2.8 years ago by jerald0
2
gravatar for Philipp Bayer
2.8 years ago by
Philipp Bayer6.6k
Australia/Perth/UWA
Philipp Bayer6.6k wrote:

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 COMMENTlink modified 2.8 years ago • written 2.8 years ago by Philipp Bayer6.6k

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 REPLYlink modified 2.8 years ago by WouterDeCoster43k • written 2.8 years ago by jerald0
1

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 REPLYlink written 2.8 years ago by WouterDeCoster43k

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

ADD REPLYlink written 2.8 years ago by jerald0
1

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 REPLYlink written 2.8 years ago by Philipp Bayer6.6k

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 REPLYlink modified 2.8 years ago • written 2.8 years ago by jerald0
1

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 REPLYlink written 2.8 years ago by Philipp Bayer6.6k

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 REPLYlink written 2.8 years ago by jerald0
1

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 REPLYlink written 2.8 years ago by Philipp Bayer6.6k

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

ADD REPLYlink written 2.8 years ago by jerald0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1083 users visited in the last hour