Question: Clustalw alignment problem
 
2
 
 

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

 
 
 

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

log in to reply • written 2.0 years ago by Khader Shameer  119711028
 
1

looks like you're using a deprecated function. have a look at the docstring: http://github.com/biopython/biopython/blob/master/Bio/Clustalw/init.py#L108

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."""

log in to reply • written 2.0 years ago by brentp  12151135
 

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

log in to reply • written 2.0 years ago by Istvan Albert ♦♦ 145511133
 

@Istvan, yep. done.

log in to reply • written 2.0 years ago by brentp  12151135
 

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

log in to reply • written 2.0 years ago by Giovanni M Dall'Olio  105011535

5 answers

 
4
 
 
 

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.

 
 
 

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

log in to reply • written 2.0 years ago by Thaman  2601416
 
 
3
 
 
 

"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')
 
 
 

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.

log in to reply • written 2.0 years ago by Peter  17228
 

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"))

log in to reply • written 2.0 years ago by Thaman  2601416
 
 
3
 
 
 

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

 
 
 
 
0
 
 
 

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

[1]: 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?

 
 
 

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.

log in to reply • written 2.0 years ago by Peter  17228
 

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.

log in to reply • written 2.0 years ago by Peter  17228
 
 
-1
 
 
 

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

 
 
 
Log in to add a post