But my "Bio.Align.Applications.ClustalwCommandline" wrapper is not working. There is import error in application, i dont know where i have mistaken.
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
6 answers
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.
"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.
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"))
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
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?
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.
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.
I think now it will be more clear with these images linked below to deliver my problem
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?
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.
Log in to answer this question.
Can you add this question as a followup of your last question, or provide a link to your last question ? Thanks.
Looks like you're using a deprecated function. have a look at the docstring, specifically:
maybe this would also be a good answer not just a comment
@Istvan, yep. done.
please don't "community wiki" unless you know what does it mean.