Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Align.Applications._Clustalw.ClustalwCommandline Class Reference
Inheritance diagram for Bio.Align.Applications._Clustalw.ClustalwCommandline:
Inheritance graph
[legend]
Collaboration diagram for Bio.Align.Applications._Clustalw.ClustalwCommandline:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __str__
def __repr__
def set_parameter
def __setattr__
def __call__

Public Attributes

 parameters
 program_name

Detailed Description

Command line wrapper for clustalw (version one or two).

http://www.clustal.org/

Example:

>>> from Bio.Align.Applications import ClustalwCommandline
>>> in_file = "unaligned.fasta"
>>> clustalw_cline = ClustalwCommandline("clustalw2", infile=in_file)
>>> print clustalw_cline
clustalw2 -infile=unaligned.fasta

You would typically run the command line with clustalw_cline() or via
the Python subprocess module, as described in the Biopython tutorial.

Citation:

Larkin MA, Blackshields G, Brown NP, Chenna R, McGettigan PA,
McWilliam H, Valentin F, Wallace IM, Wilm A, Lopez R, Thompson JD,
Gibson TJ, Higgins DG. (2007). Clustal W and Clustal X version 2.0.
Bioinformatics, 23, 2947-2948. 

Last checked against versions: 1.83 and 2.0.10

Definition at line 13 of file _Clustalw.py.


Constructor & Destructor Documentation

def Bio.Align.Applications._Clustalw.ClustalwCommandline.__init__ (   self,
  cmd = "clustalw",
  kwargs 
)
Create a new instance of a command line wrapper object.

Reimplemented from Bio.Application.AbstractCommandline.

Definition at line 39 of file _Clustalw.py.

00039 
00040     def __init__(self, cmd="clustalw", **kwargs):
00041         self.parameters = \
00042             [
00043             _Option(["-infile", "-INFILE", "INFILE", "infile"],
00044                     "Input sequences.",
00045                     filename=True),
00046             _Option(["-profile1", "-PROFILE1", "PROFILE1", "profile1"],
00047                     "Profiles (old alignment).",
00048                     filename=True),
00049             _Option(["-profile2", "-PROFILE2", "PROFILE2", "profile2"],
00050                     "Profiles (old alignment).",
00051                     filename=True),
00052             ################## VERBS (do things) #############################
00053             _Switch(["-options", "-OPTIONS", "OPTIONS", "options"],
00054                     "List the command line parameters"),
00055             _Switch(["-help", "-HELP", "HELP", "help"],
00056                     "Outline the command line params."),
00057             _Switch(["-check", "-CHECK", "CHECK", "check"],
00058                     "Outline the command line params."),
00059             _Switch(["-fullhelp", "-FULLHELP", "FULLHELP", "fullhelp"],
00060                     "Output full help content."),
00061             _Switch(["-align", "-ALIGN", "ALIGN", "align"],
00062                     "Do full multiple alignment."),
00063             _Switch(["-tree", "-TREE", "TREE", "tree"],
00064                     "Calculate NJ tree."),
00065             _Option(["-bootstrap", "-BOOTSTRAP", "BOOTSTRAP", "bootstrap"],
00066                     "Bootstrap a NJ tree (n= number of bootstraps; def. = 1000).",
00067                     checker_function=lambda x: isinstance(x, int)),
00068             _Switch(["-convert", "-CONVERT", "CONVERT", "convert"],
00069                     "Output the input sequences in a different file format."),
00070             ##################### PARAMETERS (set things) #########################
00071             # ***General settings:****
00072             # Makes no sense in biopython
00073             #_Option(["-interactive", "-INTERACTIVE", "INTERACTIVE", "interactive"],
00074             #        [],
00075             #        lambda x: 0, #Does not take value
00076             #        False,
00077             #        "read command line, then enter normal interactive menus",
00078             #        False),
00079             _Switch(["-quicktree", "-QUICKTREE", "QUICKTREE", "quicktree"],
00080                     "Use FAST algorithm for the alignment guide tree"),
00081             _Option(["-type", "-TYPE", "TYPE", "type"],
00082                     "PROTEIN or DNA sequences",
00083                     checker_function=lambda x: x in ["PROTEIN", "DNA",
00084                                                      "protein", "dna"]),
00085             _Switch(["-negative", "-NEGATIVE", "NEGATIVE", "negative"],
00086                     "Protein alignment with negative values in matrix"),
00087             _Option(["-outfile", "-OUTFILE", "OUTFILE", "outfile"],
00088                     "Output sequence alignment file name",
00089                     filename=True),
00090             _Option(["-output", "-OUTPUT", "OUTPUT", "output"],
00091                     "Output format: GCG, GDE, PHYLIP, PIR or NEXUS",
00092                     checker_function=lambda x: x in ["GCG", "GDE", "PHYLIP",
00093                                                      "PIR", "NEXUS",
00094                                                      "gcg", "gde", "phylip",
00095                                                      "pir", "nexus"]),
00096             _Option(["-outorder", "-OUTORDER", "OUTORDER", "outorder"],
00097                     "Output taxon order: INPUT or ALIGNED",
00098                     checker_function=lambda x: x in ["INPUT", "input",
00099                                                      "ALIGNED", "aligned"]),
00100             _Option(["-case", "-CASE", "CASE", "case"],
00101                     "LOWER or UPPER (for GDE output only)",
00102                     checker_function=lambda x: x in ["UPPER", "upper",
00103                                                      "LOWER", "lower"]),
00104             _Option(["-seqnos", "-SEQNOS", "SEQNOS", "seqnos"],
00105                     "OFF or ON (for Clustal output only)",
00106                     checker_function=lambda x: x in ["ON", "on",
00107                                                      "OFF", "off"]),
00108             _Option(["-seqno_range", "-SEQNO_RANGE", "SEQNO_RANGE", "seqno_range"],
00109                     "OFF or ON (NEW- for all output formats)",
00110                     checker_function=lambda x: x in ["ON", "on",
00111                                                      "OFF", "off"]),
00112             _Option(["-range", "-RANGE", "RANGE", "range"],
00113                     "Sequence range to write starting m to m+n. "
00114                     "Input as string eg. '24,200'"),
00115             _Option(["-maxseqlen", "-MAXSEQLEN", "MAXSEQLEN", "maxseqlen"],
00116                     "Maximum allowed input sequence length",
00117                     checker_function=lambda x: isinstance(x, int)),
00118             _Switch(["-quiet", "-QUIET", "QUIET", "quiet"],
00119                     "Reduce console output to minimum"),
00120             _Switch(["-stats", "-STATS", "STATS", "stats"],
00121                     "Log some alignents statistics to file"),
00122             # ***Fast Pairwise Alignments:***
00123             _Option(["-ktuple", "-KTUPLE", "KTUPLE", "ktuple"],
00124                     "Word size",
00125                     checker_function=lambda x: isinstance(x, int) or \
00126                                                isinstance(x, float)),
00127             _Option(["-topdiags", "-TOPDIAGS", "TOPDIAGS", "topdiags"],
00128                     "Number of best diags.",
00129                     checker_function=lambda x: isinstance(x, int) or \
00130                                                isinstance(x, float)),
00131             _Option(["-window", "-WINDOW", "WINDOW", "window"],
00132                     "Window around best diags.",
00133                     checker_function=lambda x: isinstance(x, int) or \
00134                                                isinstance(x, float)),
00135             _Option(["-pairgap", "-PAIRGAP", "PAIRGAP", "pairgap"],
00136                     "Gap penalty",
00137                     checker_function=lambda x: isinstance(x, int) or \
00138                                                isinstance(x, float)),
00139             _Option(["-score", "-SCORE", "SCORE", "score"],
00140                     "Either: PERCENT or ABSOLUTE",
00141                     checker_function=lambda x: x in ["percent", "PERCENT",
00142                                                      "absolute","ABSOLUTE"]),
00143             # ***Slow Pairwise Alignments:***
00144             _Option(["-pwmatrix", "-PWMATRIX", "PWMATRIX", "pwmatrix"],
00145                     "Protein weight matrix=BLOSUM, PAM, GONNET, ID or filename",
00146                     checker_function=lambda x: x in ["BLOSUM", "PAM",
00147                                                      "GONNET", "ID",
00148                                                      "blosum", "pam",
00149                                                      "gonnet", "id"] or \
00150                                                 os.path.exists(x),
00151                     filename=True),
00152             _Option(["-pwdnamatrix", "-PWDNAMATRIX", "PWDNAMATRIX", "pwdnamatrix"],
00153                     "DNA weight matrix=IUB, CLUSTALW or filename",
00154                     checker_function=lambda x: x in ["IUB", "CLUSTALW",
00155                                                      "iub", "clustalw"] or \
00156                                                os.path.exists(x),
00157                     filename=True),
00158             _Option(["-pwgapopen", "-PWGAPOPEN", "PWGAPOPEN", "pwgapopen"],
00159                     "Gap opening penalty",
00160                     checker_function=lambda x: isinstance(x, int) or \
00161                                                isinstance(x, float)),
00162             _Option(["-pwgapext", "-PWGAPEXT", "PWGAPEXT", "pwgapext"],
00163                     "Gap opening penalty",
00164                     checker_function=lambda x: isinstance(x, int) or \
00165                                                isinstance(x, float)),
00166             # ***Multiple Alignments:***
00167             _Option(["-newtree", "-NEWTREE", "NEWTREE", "newtree"],
00168                     "Output file name for newly created guide tree",
00169                     filename=True),
00170             _Option(["-usetree", "-USETREE", "USETREE", "usetree"],
00171                     "File name of guide tree",
00172                     checker_function=lambda x: os.path.exists,
00173                     filename=True),
00174             _Option(["-matrix", "-MATRIX", "MATRIX", "matrix"],
00175                     "Protein weight matrix=BLOSUM, PAM, GONNET, ID or filename",
00176                     checker_function=lambda x: x in ["BLOSUM", "PAM",
00177                                                      "GONNET", "ID",
00178                                                      "blosum", "pam",
00179                                                      "gonnet", "id"] or \
00180                                                os.path.exists(x),
00181                     filename=True),
00182             _Option(["-dnamatrix", "-DNAMATRIX", "DNAMATRIX", "dnamatrix"],
00183                     "DNA weight matrix=IUB, CLUSTALW or filename",
00184                     checker_function=lambda x: x in ["IUB", "CLUSTALW",
00185                                                      "iub", "clustalw"] or \
00186                                                os.path.exists(x),
00187                     filename=True),
00188             _Option(["-gapopen", "-GAPOPEN", "GAPOPEN", "gapopen"],
00189                     "Gap opening penalty",
00190                     checker_function=lambda x: isinstance(x, int) or \
00191                                                isinstance(x, float)),
00192             _Option(["-gapext", "-GAPEXT", "GAPEXT", "gapext"],
00193                     "Gap extension penalty",
00194                     checker_function=lambda x: isinstance(x, int) or \
00195                                                isinstance(x, float)),
00196             _Switch(["-endgaps", "-ENDGAPS", "ENDGAPS", "endgaps"],
00197                     "No end gap separation pen."),
00198             _Option(["-gapdist", "-GAPDIST", "GAPDIST", "gapdist"],
00199                     "Gap separation pen. range",
00200                     checker_function=lambda x: isinstance(x, int) or \
00201                                                isinstance(x, float)),
00202             _Switch(["-nopgap", "-NOPGAP", "NOPGAP", "nopgap"],
00203                     "Residue-specific gaps off"),
00204             _Switch(["-nohgap", "-NOHGAP", "NOHGAP", "nohgap"],
00205                     "Hydrophilic gaps off"),
00206             _Switch(["-hgapresidues", "-HGAPRESIDUES", "HGAPRESIDUES", "hgapresidues"],
00207                     "List hydrophilic res."),
00208             _Option(["-maxdiv", "-MAXDIV", "MAXDIV", "maxdiv"],
00209                     "% ident. for delay",
00210                     checker_function=lambda x: isinstance(x, int) or \
00211                                                isinstance(x, float)),
00212             _Option(["-transweight", "-TRANSWEIGHT", "TRANSWEIGHT", "transweight"],
00213                     "Transitions weighting",
00214                     checker_function=lambda x: isinstance(x, int) or \
00215                                                isinstance(x, float)),
00216             _Option(["-iteration", "-ITERATION", "ITERATION", "iteration"],
00217                     "NONE or TREE or ALIGNMENT",
00218                     checker_function=lambda x: x in ["NONE", "TREE",
00219                                                      "ALIGNMENT",
00220                                                      "none", "tree",
00221                                                      "alignment"]),
00222             _Option(["-numiter", "-NUMITER", "NUMITER", "numiter"],
00223                     "maximum number of iterations to perform",
00224                     checker_function=lambda x: isinstance(x, int)),
00225             _Switch(["-noweights", "-NOWEIGHTS", "NOWEIGHTS", "noweights"],
00226                     "Disable sequence weighting"),
00227             # ***Profile Alignments:***
00228             _Switch(["-profile", "-PROFILE", "PROFILE", "profile"],
00229                     "Merge two alignments by profile alignment"),
00230             _Option(["-newtree1", "-NEWTREE1", "NEWTREE1", "newtree1"],
00231                     "Output file name for new guide tree of profile1",
00232                     filename=True),
00233             _Option(["-newtree2", "-NEWTREE2", "NEWTREE2", "newtree2"],
00234                     "Output file for new guide tree of profile2",
00235                     filename=True),
00236             _Option(["-usetree1", "-USETREE1", "USETREE1", "usetree1"],
00237                     "File name of guide tree for profile1",
00238                     checker_function=lambda x: os.path.exists,
00239                     filename=True),
00240             _Option(["-usetree2", "-USETREE2", "USETREE2", "usetree2"],
00241                     "File name of guide tree for profile2",
00242                     checker_function=lambda x: os.path.exists,
00243                     filename=True),
00244             # ***Sequence to Profile Alignments:***
00245             _Switch(["-sequences", "-SEQUENCES", "SEQUENCES", "sequences"],
00246                     "Sequentially add profile2 sequences to profile1 alignment"),
00247             _Switch(["-nosecstr1", "-NOSECSTR1", "NOSECSTR1", "nosecstr1"],
00248                     "Do not use secondary structure-gap penalty mask for profile 1"),
00249             _Switch(["-nosecstr2", "-NOSECSTR2", "NOSECSTR2", "nosecstr2"],
00250                     "Do not use secondary structure-gap penalty mask for profile 2"),
00251             # ***Structure Alignments:***
00252             _Option(["-secstrout", "-SECSTROUT", "SECSTROUT", "secstrout"],
00253                     "STRUCTURE or MASK or BOTH or NONE output in alignment file",
00254                     checker_function=lambda x: x in ["STRUCTURE", "MASK",
00255                                                      "BOTH", "NONE",
00256                                                      "structure", "mask",
00257                                                      "both", "none"]),
00258             _Option(["-helixgap", "-HELIXGAP", "HELIXGAP", "helixgap"],
00259                     "Gap penalty for helix core residues",
00260                     checker_function=lambda x: isinstance(x, int) or \
00261                                                isinstance(x, float)),
00262             _Option(["-strandgap", "-STRANDGAP", "STRANDGAP", "strandgap"],
00263                     "gap penalty for strand core residues",
00264                     checker_function=lambda x: isinstance(x, int) or \
00265                                                isinstance(x, float)),
00266             _Option(["-loopgap", "-LOOPGAP", "LOOPGAP", "loopgap"],
00267                     "Gap penalty for loop regions",
00268                     checker_function=lambda x: isinstance(x, int) or \
00269                                                isinstance(x, float)),
00270             _Option(["-terminalgap", "-TERMINALGAP", "TERMINALGAP", "terminalgap"],
00271                     "Gap penalty for structure termini",
00272                     checker_function=lambda x: isinstance(x, int) or \
00273                                                isinstance(x, float)),
00274             _Option(["-helixendin", "-HELIXENDIN", "HELIXENDIN", "helixendin"],
00275                     "Number of residues inside helix to be treated as terminal",
00276                     checker_function=lambda x: isinstance(x, int)),
00277             _Option(["-helixendout", "-HELIXENDOUT", "HELIXENDOUT", "helixendout"],
00278                     "Number of residues outside helix to be treated as terminal",
00279                     checker_function=lambda x: isinstance(x, int)),
00280             _Option(["-strandendin", "-STRANDENDIN", "STRANDENDIN", "strandendin"],
00281                     "Number of residues inside strand to be treated as terminal",
00282                     checker_function=lambda x: isinstance(x, int)),
00283             _Option(["-strandendout", "-STRANDENDOUT", "STRANDENDOUT", "strandendout"],
00284                     "number of residues outside strand to be treated as terminal",
00285                     checker_function=lambda x: isinstance(x, int)),
00286             # ***Trees:***
00287             _Option(["-outputtree", "-OUTPUTTREE", "OUTPUTTREE", "outputtree"],
00288                     "nj OR phylip OR dist OR nexus",
00289                     checker_function=lambda x: x in ["NJ", "PHYLIP",
00290                                                      "DIST", "NEXUS",
00291                                                      "nj", "phylip",
00292                                                      "dist", "nexus"]),
00293             _Option(["-seed", "-SEED", "SEED", "seed"],
00294                     "Seed number for bootstraps.",
00295                     checker_function=lambda x: isinstance(x, int)),
00296             _Switch(["-kimura", "-KIMURA", "KIMURA", "kimura"],
00297                     "Use Kimura's correction."),
00298             _Switch(["-tossgaps", "-TOSSGAPS", "TOSSGAPS", "tossgaps"],
00299                     "Ignore positions with gaps."),
00300             _Option(["-bootlabels", "-BOOTLABELS", "BOOTLABELS", "bootlabels"],
00301                     "Node OR branch position of bootstrap values in tree display",
00302                     checker_function=lambda x: x in ["NODE", "BRANCH",
00303                                                      "node", "branch"]),
00304             _Option(["-clustering", "-CLUSTERING", "CLUSTERING", "clustering"],
00305                     "NJ or UPGMA",
00306                     checker_function=lambda x: x in ["NJ", "UPGMA", "nj", "upgma"])
00307             ]
00308         AbstractCommandline.__init__(self, cmd, **kwargs)

Here is the caller graph for this function:


Member Function Documentation

def Bio.Application.AbstractCommandline.__call__ (   self,
  stdin = None,
  stdout = True,
  stderr = True,
  cwd = None,
  env = None 
) [inherited]
Executes the command, waits for it to finish, and returns output.

Runs the command line tool and waits for it to finish. If it returns
a non-zero error level, an exception is raised. Otherwise two strings
are returned containing stdout and stderr.

The optional stdin argument should be a string of data which will be
passed to the tool as standard input.

The optional stdout and stderr argument are treated as a booleans, and
control if the output should be captured (True, default), or ignored
by sending it to /dev/null to avoid wasting memory (False). In the
later case empty string(s) are returned.

The optional cwd argument is a string giving the working directory to
to run the command from. See Python's subprocess module documentation
for more details.

The optional env argument is a dictionary setting the environment
variables to be used in the new process. By default the current
process' environment variables are used. See Python's subprocess
module documentation for more details.

Default example usage:

from Bio.Emboss.Applications import WaterCommandline
water_cmd = WaterCommandline(gapopen=10, gapextend=0.5,
                     stdout=True, auto=True,
                     asequence="a.fasta", bsequence="b.fasta")
print "About to run:\n%s" % water_cmd
std_output, err_output = water_cmd()

This functionality is similar to subprocess.check_output() added in
Python 2.7. In general if you require more control over running the
command, use subprocess directly.

As of Biopython 1.56, when the program called returns a non-zero error
level, a custom ApplicationError exception is raised. This includes
any stdout and stderr strings captured as attributes of the exception
object, since they may be useful for diagnosing what went wrong.

Definition at line 368 of file __init__.py.

00368 
00369                  cwd=None, env=None):
00370         """Executes the command, waits for it to finish, and returns output.
00371         
00372         Runs the command line tool and waits for it to finish. If it returns
00373         a non-zero error level, an exception is raised. Otherwise two strings
00374         are returned containing stdout and stderr.
00375         
00376         The optional stdin argument should be a string of data which will be
00377         passed to the tool as standard input.
00378 
00379         The optional stdout and stderr argument are treated as a booleans, and
00380         control if the output should be captured (True, default), or ignored
00381         by sending it to /dev/null to avoid wasting memory (False). In the
00382         later case empty string(s) are returned.
00383 
00384         The optional cwd argument is a string giving the working directory to
00385         to run the command from. See Python's subprocess module documentation
00386         for more details.
00387 
00388         The optional env argument is a dictionary setting the environment
00389         variables to be used in the new process. By default the current
00390         process' environment variables are used. See Python's subprocess
00391         module documentation for more details.
00392 
00393         Default example usage:
00394 
00395         from Bio.Emboss.Applications import WaterCommandline
00396         water_cmd = WaterCommandline(gapopen=10, gapextend=0.5,
00397                                      stdout=True, auto=True,
00398                                      asequence="a.fasta", bsequence="b.fasta")
00399         print "About to run:\n%s" % water_cmd
00400         std_output, err_output = water_cmd()
00401 
00402         This functionality is similar to subprocess.check_output() added in
00403         Python 2.7. In general if you require more control over running the
00404         command, use subprocess directly.
00405         
00406         As of Biopython 1.56, when the program called returns a non-zero error
00407         level, a custom ApplicationError exception is raised. This includes
00408         any stdout and stderr strings captured as attributes of the exception
00409         object, since they may be useful for diagnosing what went wrong.
00410         """
00411         if stdout:
00412             stdout_arg = subprocess.PIPE
00413         else:
00414             stdout_arg = open(os.devnull)
00415         if stderr:
00416             stderr_arg = subprocess.PIPE
00417         else:
00418             stderr_arg = open(os.devnull)
00419         #We may not need to supply any piped input, but we setup the
00420         #standard input pipe anyway as a work around for a python
00421         #bug if this is called from a Windows GUI program.  For
00422         #details, see http://bugs.python.org/issue1124861
00423         #
00424         #Using universal newlines is important on Python 3, this
00425         #gives unicode handles rather than bytes handles.
00426         child_process = subprocess.Popen(str(self), stdin=subprocess.PIPE,
00427                                          stdout=stdout_arg, stderr=stderr_arg,
00428                                          universal_newlines=True,
00429                                          cwd=cwd, env=env,
00430                                          shell=(sys.platform!="win32"))
00431         #Use .communicate as can get deadlocks with .wait(), see Bug 2804
00432         stdout_str, stderr_str = child_process.communicate(stdin)
00433         if not stdout: assert not stdout_str
00434         if not stderr: assert not stderr_str
00435         return_code = child_process.returncode
00436         if return_code:
00437             raise ApplicationError(return_code, str(self),
00438                                    stdout_str, stderr_str)
00439         return stdout_str, stderr_str
00440 

Here is the call graph for this function:

Here is the caller graph for this function:

Return a representation of the command line object for debugging.

e.g.
>>> from Bio.Emboss.Applications import WaterCommandline
>>> cline = WaterCommandline(gapopen=10, gapextend=0.5)
>>> cline.asequence = "asis:ACCCGGGCGCGGT"
>>> cline.bsequence = "asis:ACCCGAGCGCGGT"
>>> cline.outfile = "temp_water.txt"
>>> print cline
water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5
>>> cline
WaterCommandline(cmd='water', outfile='temp_water.txt', asequence='asis:ACCCGGGCGCGGT', bsequence='asis:ACCCGAGCGCGGT', gapopen=10, gapextend=0.5)

Definition at line 251 of file __init__.py.

00251 
00252     def __repr__(self):
00253         """Return a representation of the command line object for debugging.
00254 
00255         e.g.
00256         >>> from Bio.Emboss.Applications import WaterCommandline
00257         >>> cline = WaterCommandline(gapopen=10, gapextend=0.5)
00258         >>> cline.asequence = "asis:ACCCGGGCGCGGT"
00259         >>> cline.bsequence = "asis:ACCCGAGCGCGGT"
00260         >>> cline.outfile = "temp_water.txt"
00261         >>> print cline
00262         water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5
00263         >>> cline
00264         WaterCommandline(cmd='water', outfile='temp_water.txt', asequence='asis:ACCCGGGCGCGGT', bsequence='asis:ACCCGAGCGCGGT', gapopen=10, gapextend=0.5)
00265         """
00266         answer = "%s(cmd=%s" % (self.__class__.__name__, repr(self.program_name))
00267         for parameter in self.parameters:
00268             if parameter.is_set:
00269                 if isinstance(parameter, _Switch):
00270                     answer += ", %s=True" % parameter.names[-1]
00271                 else:
00272                     answer += ", %s=%s" \
00273                               % (parameter.names[-1], repr(parameter.value))
00274         answer += ")"
00275         return answer

def Bio.Application.AbstractCommandline.__setattr__ (   self,
  name,
  value 
) [inherited]
Set attribute name to value (PRIVATE).

This code implements a workaround for a user interface issue.
Without this __setattr__ attribute-based assignment of parameters
will silently accept invalid parameters, leading to known instances
of the user assuming that parameters for the application are set,
when they are not.

>>> from Bio.Emboss.Applications import WaterCommandline
>>> cline = WaterCommandline(gapopen=10, gapextend=0.5, stdout=True)
>>> cline.asequence = "a.fasta"
>>> cline.bsequence = "b.fasta"
>>> cline.csequence = "c.fasta"
Traceback (most recent call last):
...
ValueError: Option name csequence was not found.
>>> print cline
water -stdout -asequence=a.fasta -bsequence=b.fasta -gapopen=10 -gapextend=0.5

This workaround uses a whitelist of object attributes, and sets the
object attribute list as normal, for these.  Other attributes are
assumed to be parameters, and passed to the self.set_parameter method
for validation and assignment.

Definition at line 337 of file __init__.py.

00337 
00338     def __setattr__(self, name, value):
00339         """Set attribute name to value (PRIVATE).
00340 
00341         This code implements a workaround for a user interface issue.
00342         Without this __setattr__ attribute-based assignment of parameters
00343         will silently accept invalid parameters, leading to known instances
00344         of the user assuming that parameters for the application are set,
00345         when they are not.
00346         
00347         >>> from Bio.Emboss.Applications import WaterCommandline
00348         >>> cline = WaterCommandline(gapopen=10, gapextend=0.5, stdout=True)
00349         >>> cline.asequence = "a.fasta"
00350         >>> cline.bsequence = "b.fasta"
00351         >>> cline.csequence = "c.fasta"
00352         Traceback (most recent call last):
00353         ...
00354         ValueError: Option name csequence was not found.
00355         >>> print cline
00356         water -stdout -asequence=a.fasta -bsequence=b.fasta -gapopen=10 -gapextend=0.5
00357 
00358         This workaround uses a whitelist of object attributes, and sets the
00359         object attribute list as normal, for these.  Other attributes are
00360         assumed to be parameters, and passed to the self.set_parameter method
00361         for validation and assignment.
00362         """
00363         if name in ['parameters', 'program_name']: # Allowed attributes
00364             self.__dict__[name] = value
00365         else:
00366             self.set_parameter(name, value)  # treat as a parameter
    

Here is the call graph for this function:

def Bio.Application.AbstractCommandline.__str__ (   self) [inherited]
Make the commandline string with the currently set options.

e.g.
>>> from Bio.Emboss.Applications import WaterCommandline
>>> cline = WaterCommandline(gapopen=10, gapextend=0.5)
>>> cline.asequence = "asis:ACCCGGGCGCGGT"
>>> cline.bsequence = "asis:ACCCGAGCGCGGT"
>>> cline.outfile = "temp_water.txt"
>>> print cline
water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5
>>> str(cline)
'water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5'

Definition at line 229 of file __init__.py.

00229 
00230     def __str__(self):
00231         """Make the commandline string with the currently set options.
00232 
00233         e.g.
00234         >>> from Bio.Emboss.Applications import WaterCommandline
00235         >>> cline = WaterCommandline(gapopen=10, gapextend=0.5)
00236         >>> cline.asequence = "asis:ACCCGGGCGCGGT"
00237         >>> cline.bsequence = "asis:ACCCGAGCGCGGT"
00238         >>> cline.outfile = "temp_water.txt"
00239         >>> print cline
00240         water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5
00241         >>> str(cline)
00242         'water -outfile=temp_water.txt -asequence=asis:ACCCGGGCGCGGT -bsequence=asis:ACCCGAGCGCGGT -gapopen=10 -gapextend=0.5'
00243         """
00244         self._validate()
00245         commandline = "%s " % self.program_name
00246         for parameter in self.parameters:
00247             if parameter.is_set:
00248                 #This will include a trailing space:
00249                 commandline += str(parameter)
00250         return commandline.strip() # remove trailing space

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Application.AbstractCommandline.set_parameter (   self,
  name,
  value = None 
) [inherited]
Set a commandline option for a program.

Definition at line 297 of file __init__.py.

00297 
00298     def set_parameter(self, name, value = None):
00299         """Set a commandline option for a program.
00300         """
00301         set_option = False
00302         for parameter in self.parameters:
00303             if name in parameter.names:
00304                 if isinstance(parameter, _Switch):
00305                     if value is None:
00306                         import warnings
00307                         warnings.warn("For a switch type argument like %s, "
00308                                       "we expect a boolean.  None is treated "
00309                                       "as FALSE!" % parameter.names[-1])
00310                     parameter.is_set = bool(value)
00311                     set_option = True
00312                 else:
00313                     if value is not None:
00314                         self._check_value(value, name, parameter.checker_function)
00315                         parameter.value = value
00316                     parameter.is_set = True
00317                     set_option = True
00318         if not set_option:
00319             raise ValueError("Option name %s was not found." % name)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 40 of file _Clustalw.py.

Reimplemented in Bio.Align.Applications._Dialign.DialignCommandline.

Definition at line 167 of file __init__.py.


The documentation for this class was generated from the following file: