Question: Clustalw Alignment Problem
2
gravatar for Thaman
9.4 years ago by
Thaman3.2k
Finland
Thaman3.2k wrote:

Hi everyone,

I tried these lines

................................................

import os
from Bio.Clustalw import MultipleAlignCL

cline = MultipleAlignCL(os.path.join(os.curdir, "opuntia.fasta"))
cline.set_output("test.aln")
alignment = Clustalw.do_alignment(cline)

.............................................

But couldn't proceed with these errors

.............................................

Traceback (most recent call last):
  File "<string>", line 244, in run_nodebug
  File "C:\Python24\align.py", line 5, in ?
    alignment = Clustalw.do_alignment(cline)
  File "C:\Python24\lib\site-packages\Bio\Clustalw\__init__.py", line 95, in do_alignment
    shell=(sys.platform!="win32")
  File "C:\Python24\lib\subprocess.py", line 534, in __init__
    (p2cread, p2cwrite,
  File "C:\Python24\lib\subprocess.py", line 594, in _get_handles
    p2cread = self._make_inheritable(p2cread)
  File "C:\Python24\lib\subprocess.py", line 635, in _make_inheritable
    DUPLICATE_SAME_ACCESS)

TypeError: an integer is required

.................................................

test.aln is not generated too

..................................................

Thanks

biopython clustalw alignment • 5.0k views
ADD COMMENTlink modified 13 months ago by anyjjhmx0 • written 9.4 years ago by Thaman3.2k
1

Looks like you're using a deprecated function. have a look at the docstring, specifically:

"""

This function (and the associated command line object) are now obsolete.

Please use the Bio.Align.Applications.ClustalwCommandline wrapper with

the Python subprocess module (and Bio.AlignIO for parsing) as described

in the tutorial.

"""

ADD REPLYlink modified 13 months ago by RamRS24k • written 9.4 years ago by brentp23k

Can you add this question as a followup of your last question, or provide a link to your last question ? Thanks.

ADD REPLYlink written 9.4 years ago by Khader Shameer18k

maybe this would also be a good answer not just a comment

ADD REPLYlink written 9.4 years ago by Istvan Albert ♦♦ 81k

@Istvan, yep. done.

ADD REPLYlink written 9.4 years ago by brentp23k

please don't "community wiki" unless you know what does it mean.

ADD REPLYlink written 9.4 years ago by Giovanni M Dall'Olio26k
4
gravatar for brentp
9.4 years ago by
brentp23k
Salt Lake City, UT
brentp23k wrote:

looks like you're using a deprecated function. Have a look at the docstring. specifically:

This function (and the associated command line object) are now obsolete. Please use the Bio.Align.Applications.ClustalwCommandline wrapper with the Python subprocess module (and Bio.AlignIO for parsing) as described in the tutorial.

ADD COMMENTlink modified 13 months ago by RamRS24k • written 9.4 years ago by brentp23k

But my "Bio.Align.Applications.ClustalwCommandline" wrapper is not working. There is import error in application, i dont know where i have mistaken.

ADD REPLYlink written 9.4 years ago by Thaman3.2k
3
gravatar for Thaman
9.4 years ago by
Thaman3.2k
Finland
Thaman3.2k wrote:

"Bio.Align.Applications import ClustalwCommandline" wrapper isn't working.There is error stated as "importerror: no module named applications", i dont know where i have mistaken though code seems clear enough.

..............................

import sys,os, subprocess
from Bio import AlignIO
from Bio.Align.Applications import ClustalCommandline

cline = ClustalCommandline(input="opuntia.fasta")
child = subprocess.call(str(cline),
  stdout=subprocess.PIPE,
  shell=(sys.platform!="win32"))

align = AlignIO.read(child.stdout, "fasta")
AlignIO.write([align], open('opuntia.phy', 'w+'), 'phylip')
ADD COMMENTlink modified 13 months ago by RamRS24k • written 9.4 years ago by Thaman3.2k

Assuming you haven't got the case wrong (e.g. Applications versus applications), then the ImportError probably means your Biopython is too old. You'll need at least Biopython 1.51.

ADD REPLYlink written 9.4 years ago by Peter5.8k

I installed new version of biopython compatible with python. When i run the same code then i can't see the alignment ouput (.aln or .dnd) generated.

import sys,os, subprocess
from Bio import AlignIO
from Bio.Align.Applications import ClustalCommandline
cline = ClustalCommandline(input="opuntia.fasta")
child = subprocess.call(str(cline),
  stdout=subprocess.PIPE,
  shell=(sys.platform!="win32"))
ADD REPLYlink modified 13 months ago by RamRS24k • written 9.4 years ago by Thaman3.2k
3
gravatar for Peter
9.4 years ago by
Peter5.8k
Scotland, UK
Peter5.8k wrote:

Although as Brent has pointed out the Bio.Clustalw.do_alignment function is considered to be obsolete, the example does run fine for me using Mac and Windows (once the missing line "from Bio import Clustalw" is added).

Could you try updating to your Python installation, and/or running this at the python prompt at the windows command line (a "DOS" shell)? I think you are seeing an old Windows non-command line specific bug in Python's subprocess module: http://bugs.python.org/issue1124861

ADD COMMENTlink written 9.4 years ago by Peter5.8k
0
gravatar for Thaman
9.4 years ago by
Thaman3.2k
Finland
Thaman3.2k wrote:

Got new configuration:

  • Python26
  • Biopython 1.54
  • Clustalw2

import sys,os, subprocess

from Bio import AlignIO
from Bio.Align.Applications import ClustalwCommandline

ClustalwCommandline("clustalw2", infile="opuntia.fasta")
return_code = subprocess.call(str(cline),
                 stdout = subprocess.PIPE,
                 shell=(sys.platform!="win32"))

According to the code i think it should generate (opuntia.aln and opuntia.dnd) files automatically after run. But, i am not getting these output files. I tried to figure out from http://www.biopython.org/DIST/docs/tutorial/Tutorial.html#htoc75 but not working :(

I get -1 while printing return_code instead of 0

Any suggestions?

ADD COMMENTlink modified 13 months ago by RamRS24k • written 9.4 years ago by Thaman3.2k

You can see the command line used with:

print str(cline)

Check this works by trying it manually (copy and paste to the Windows command prompt). My guess is you don't have clustalw.exe on the path (and you are not giving a full path), or you don't have opuntia.fasta in the current directory.

ADD REPLYlink written 9.4 years ago by Peter5.8k

You can see the command line used with "print str(cline)". Check this works by trying it manually (copy and paste to the Windows command prompt). My guess is you don't have clustalw.exe on the path (and you are not giving a full path), or you don't have opuntia.fasta in the current directory.

ADD REPLYlink written 9.4 years ago by Peter5.8k
0
gravatar for Thaman
9.4 years ago by
Thaman3.2k
Finland
Thaman3.2k wrote:

I think now it will be more clear with these images linked below to deliver my problem

system environment

Command prompt execution

Even when i tried with full path couldn't generate output (.aln or .dnd). Doesn't it mean that successful run should generate output in the same directory?

Full Path Run

ADD COMMENTlink modified 9.4 years ago • written 9.4 years ago by Thaman3.2k
0
gravatar for anyjjhmx
13 months ago by
anyjjhmx0
anyjjhmx0 wrote:

In between the Clustalw Alignment, the main problem is oriented to the import function calling, for that, you can use Linksys tech support for the alternative function calls by that, it can easily import the client part to compile the code.

ADD COMMENTlink written 13 months ago by anyjjhmx0
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: 1942 users visited in the last hour