Clustalw Alignment Problem
6
2
Entering edit mode
14.5 years ago
Thaman ★ 3.3k

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

clustalw alignment biopython • 8.2k views
ADD COMMENT
1
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

@Istvan, yep. done.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
4
Entering edit mode
14.5 years ago
brentp 24k

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 COMMENT
0
Entering edit mode

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

ADD REPLY
3
Entering edit mode
14.5 years ago
Thaman ★ 3.3k

"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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
3
Entering edit mode
14.5 years ago
Peter 6.0k

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 COMMENT
0
Entering edit mode
14.5 years ago
Thaman ★ 3.3k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
14.5 years ago
Thaman ★ 3.3k

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 COMMENT
0
Entering edit mode
6.2 years ago
anyjjhmx • 0

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 COMMENT

Login before adding your answer.

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