How To Run Clustalw Using Commands From An Input File
2
4
Entering edit mode
13.4 years ago
NPalopoli ▴ 290

I would like to run CLUSTAL 2.0.10 on an Unix system from the command line, but instead of passing options and arguments interactively, answering to the program when it asks p.g. for file names or formatting options, I need to pass them through a script or input file silently. Is there any way of doing this? Thanks in advance.

clustalw command-line sequence alignment • 22k views
ADD COMMENT
1
Entering edit mode

you have to search for "clustal batch mode" in a search engine. By the way, note that the current clustalw version is 2.1

ADD REPLY
0
Entering edit mode

don't worry, it took me an hour of google-ing to find it last time I needed it.

ADD REPLY
8
Entering edit mode
13.4 years ago
Prateek ★ 1.0k

You can run clustalw as a command passing it -INFILE , -PROFILE1 , PROFILE2 etc params without getting into user input mode. Make sure clustalw executable is in your PATH variable [HTML][HTML]here are the options[HTML] http://www.sacs.ucsf.edu/Documentation/seqsoftware/ClustalW1.7/help9.html

ADD COMMENT
0
Entering edit mode

Thanks for the answer. You have pointed to the Help page of an old version of clustalw (1.7, currently 2.0.10) which is a little outdated. Nevertheless it helped me to find out that it is possible to get the equivalent Help for current clustalw 2.0.10 just by running clustalw -help or clustalw -FULLHELP

ADD REPLY
7
Entering edit mode
13.4 years ago
Thaman ★ 3.3k

I had a big headache when solving this problem 6 months back when I didn't knew anything. But anyway now I can write you in detail how to do it silently through script.

import subprocess
from Bio.Align.Applications import ClustalwCommandline
cline = ClustalwCommandline("clustalw2", infile="opuntia.fasta", seqnos="ON", gapopen=2, gapext=0.5)
child = subprocess.call(str(cline), shell=(sys.platform!="win32"))
  • Importing clustalw command line wrapper
  • Subprocess - The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes

Other parameters available

  • Gap open penalty: -gapopen
  • Gap extension penalty: -gapext
  • no end gap(yes, no): -endgaps
  • gap distance: -gapdist
  • weight matrix(blosum, pam etc): -matrix ["BLOSUM", "PAM", "GONNET", "ID"]
  • type (DNA,protein): -type

It's easy to check the availabe parameters/options after wrapper have been created. Suppose from the above given example:

>>> cline = ClustalwCommandline(type='dna')
>>> dir(cline)
['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', 
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__setattr__', '__str__', '__weakref__', '_check_value', '_clear_parameter', 
'_get_parameter', '_validate', 'align', 'bootlabels', 'bootstrap', 'case', 'check', 
'clustering', 'convert', 'dnamatrix', 'endgaps', 'fullhelp', 'gapdist', 'gapext', 
'gapopen', 'helixendin', 'helixendout', 'helixgap', 'help', 'hgapresidues', 'infile',  
'iteration', 'kimura', 'ktuple', 'loopgap', 'matrix', 'maxdiv', 'maxseqlen',
'negative', 'newtree', 'newtree1', 'newtree2', 'nohgap', 'nopgap', 'nosecstr1',
'nosecstr2', 'noweights', 'numiter', 
'options', 'outfile', 'outorder', 'output', 'outputtree', 'pairgap', 'parameters', 
'profile', 'profile1', 'profile2', 'program_name', 'pwdnamatrix', 'pwgapext', 
'pwgapopen', 'pwmatrix', 'quicktree', 'quiet', 'range', 'score', 'secstrout', 'seed', 
'seqno_range', 'seqnos', 'sequences', 'set_parameter', 'stats', 'strandendin',  
'strandendout', 'strandgap', 
'terminalgap', 'topdiags', 'tossgaps', 'transweight', 'tree', 'type', 'usetree',  
'usetree1', 'usetree2', 'window']

>>> print cline
clustalw2 -infile=opuntia.fasta -seqnos=ON -gapopen=2 -gapext=0.5

Before writing script you can first try by importing clustalwcommandline wrapper object play by passing parameters through shell/command line.

More information and Links

Note- If you are using under windows then its important to put the clustalw on the system variable path

Hope it helps :)

ADD COMMENT
1
Entering edit mode

Thanks for your help. I was just asking for help with running clustalw from the command line; instead you are showing how to run the program using some Bio: library (I thinks it's Biopython, right?). Though this is more than I needed, it should be useful for someone and I thank you for addressing this issue in such a complete way.

ADD REPLY
0
Entering edit mode

wao! this guy was really angry. Sorry that your question wasn't answered as anticipated.

ADD REPLY

Login before adding your answer.

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