Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Phylo.Applications._Raxml.RaxmlCommandline Class Reference
Inheritance diagram for Bio.Phylo.Applications._Raxml.RaxmlCommandline:
Inheritance graph
[legend]
Collaboration diagram for Bio.Phylo.Applications._Raxml.RaxmlCommandline:
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
 parsimony_seed
 program_name

Detailed Description

Command-line wrapper for the tree inference program RAxML.

The required parameters are 'sequences' (-s), 'model' (-m) and 'name' (-n).
The parameter 'parsimony_seed' (-p) must also be set for RAxML, but if you
do not specify it, this wrapper will set the seed to 10000 for you.

Example:

>>> from Bio.Phylo.Applications import RaxmlCommandline
>>> raxml_cline = RaxmlCommandline(sequences="Tests/Phylip/interlaced2.phy",
...                                model="PROTCATWAG", name="interlaced2")
>>> print raxml_cline
raxmlHPC -m PROTCATWAG -n interlaced2 -p 10000 -s Tests/Phylip/interlaced2.phy

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

Citation:

Stamatakis A.
RAxML-VI-HPC: Maximum Likelihood-based Phylogenetic Analyses with
Thousands of Taxa and Mixed Models.
Bioinformatics 2006, 22(21):2688-2690.

Homepage: http://sco.h-its.org/exelixis/software.html

Definition at line 15 of file _Raxml.py.


Constructor & Destructor Documentation

def Bio.Phylo.Applications._Raxml.RaxmlCommandline.__init__ (   self,
  cmd = 'raxmlHPC',
  kwargs 
)
Create a new instance of a command line wrapper object.

Reimplemented from Bio.Application.AbstractCommandline.

Definition at line 43 of file _Raxml.py.

00043 
00044     def __init__(self, cmd='raxmlHPC', **kwargs):
00045         self.parameters = [
00046                 _Option(['-a', 'weight_filename'],
00047                     "Name of a column weight file to assign individual weights "
00048                     "to each column of the alignment. Those weights must be "
00049                     "integers separated by any type and number of whitespaces "
00050                     "within a separate file.",
00051                     filename=True,
00052                     equate=False,
00053                     ),
00054 
00055                 _Option(['-b', 'bootstrap_seed'],
00056                     "Random seed for bootstrapping.",
00057                     equate=False,
00058                     ),
00059 
00060                 _Option(['-c', 'num_categories'],
00061                     "Number of distinct rate categories for RAxML when "
00062                     "evolution model is set to GTRCAT or GTRMIX."
00063                     "Individual per-site rates are categorized into this "
00064                     "many rate categories to accelerate computations. "
00065                     "Default: 25.",
00066                     equate=False,
00067                     ),
00068 
00069                 _Switch(['-d', 'random_starting_tree'],
00070                     "Start ML optimization from random starting tree."
00071                     ),
00072 
00073                 _Option(['-e', 'epsilon'],
00074                     "Set model optimization precision in log likelihood units "
00075                     "for final optimization of tree topology under MIX/MIXI "
00076                     "or GAMMA/GAMMAI."
00077                     "Default: 0.1 for models not using proportion of "
00078                     "invariant sites estimate; 0.001 for models using "
00079                     "proportion of invariant sites estimate.",
00080                     equate=False,
00081                     ),
00082 
00083                 _Option(['-E', 'exclude_filename'],
00084                     "An exclude file name, containing a specification of "
00085                     "alignment positions you wish to exclude.  Format is "
00086                     "similar to Nexus, the file shall contain entries like "
00087                     "'100-200 300-400'; to exclude a single column write, "
00088                     "e.g., '100-100'. If you use a mixed model, an "
00089                     "appropriately adapted model file will be written.",
00090                     filename=True,
00091                     equate=False,
00092                     ),
00093 
00094                 _Option(['-f', 'algorithm'],
00095                     """Select algorithm:
00096                     a: Rapid Bootstrap analysis and search for best-scoring ML
00097                        tree in one program run.
00098                     b: Draw bipartition information on a tree provided with '-t'
00099                        based on multiple trees (e.g. form a bootstrap) in a file
00100                        specifed by '-z'.
00101                     c: Check if the alignment can be properly read by RAxML.
00102                     d: New rapid hill-climbing (DEFAULT).
00103                     e: Optimize model+branch lengths for given input tree under
00104                        GAMMA/GAMMAI only.
00105                     g: Compute per site log Likelihoods for one ore more trees
00106                        passed via '-z' and write them to a file that can be read
00107                        by CONSEL.
00108                     h: Compute log likelihood test (SH-test) between best tree
00109                        passed via '-t' and a bunch of other trees passed via '-z'.
00110                     i: Perform a really thorough bootstrap, refinement of final
00111                        bootstrap tree under GAMMA and a more exhaustive algorithm.
00112                     j: Generate a bunch of bootstrapped alignment files from an
00113                        original alignemnt file.
00114                     m: Compare bipartitions between two bunches of trees passed
00115                        via '-t' and '-z' respectively. This will return the
00116                        Pearson correlation between all bipartitions found in the
00117                        two tree files. A file called
00118                        RAxML_bipartitionFrequencies.outputFileName will be
00119                        printed that contains the pair-wise bipartition
00120                        frequencies of the two sets.
00121                     n: Compute the log likelihood score of all trees contained
00122                        in a tree file provided by '-z' under GAMMA or
00123                        GAMMA+P-Invar.
00124                     o: Old and slower rapid hill-climbing.
00125                     p: Perform pure stepwise MP addition of new sequences to an
00126                        incomplete starting tree.
00127                     s: Split up a multi-gene partitioned alignment into the
00128                        respective subalignments.
00129                     t: Do randomized tree searches on one fixed starting tree.
00130                     w: Compute ELW test on a bunch of trees passed via '-z'.
00131                     x: Compute pair-wise ML distances, ML model parameters will
00132                        be estimated on an MP starting tree or a user-defined
00133                        tree passed via '-t', only allowed for GAMMA-based models
00134                        of rate heterogeneity.""",
00135                     checker_function=(lambda x:
00136                         isinstance(x, basestring) and len(x) == 1),
00137                     equate=False,
00138                     ),
00139 
00140                 _Option(['-g', 'grouping_constraint'],
00141                         "File name of a multifurcating constraint tree. "
00142                         "this tree does not need to be comprehensive, i.e. "
00143                         "contain all taxa.",
00144                         filename=True,
00145                         equate=False,
00146                         ),
00147 
00148                 _Option(['-i', 'rearrangements'],
00149                         "Initial rearrangement setting for the subsequent "
00150                         "application of topological changes phase.",
00151                         equate=False,
00152                         ),
00153 
00154                 _Switch(['-j', 'checkpoints'],
00155                         "Write checkpoints (intermediate tree topologies)."
00156                         ),
00157 
00158                 _Switch(['-k', 'bootstrap_branch_lengths'],
00159                         "Print bootstrapped trees with branch lengths. "
00160                         "The bootstraps will run a bit longer, because model "
00161                         "parameters will be optimized at the end of each run. "
00162                         "Use with CATMIX/PROTMIX or GAMMA/GAMMAI."
00163                         ),
00164 
00165                 _Option(['-l', 'cluster_threshold'],
00166                         "Threshold for sequence similarity clustering. "
00167                         "RAxML will then print out an alignment to a file "
00168                         "called sequenceFileName.reducedBy.threshold that "
00169                         "only contains sequences <= the specified threshold "
00170                         "that must be between 0.0 and 1.0. RAxML uses the "
00171                         "QT-clustering algorithm to perform this task. "
00172                         "In addition, a file called "
00173                         "RAxML_reducedList.outputFileName will be written "
00174                         "that contains clustering information.",
00175                         equate=False,
00176                         ),
00177 
00178                 _Option(['-L', 'cluster_threshold_fast'],
00179                         "Same functionality as '-l', but uses a less "
00180                         "exhaustive and thus faster clustering algorithm. "
00181                         "This is intended for very large datasets with more "
00182                         "than 20,000-30,000 sequences.",
00183                         equate=False,
00184                         ),
00185 
00186                 _Option(['-m', 'model'],
00187                         """Model of Nucleotide or Amino Acid Substitution:
00188 
00189               NUCLEOTIDES:
00190 
00191                     GTRCAT         : GTR + Optimization of substitution rates + Optimization of site-specific
00192                                      evolutionary rates which are categorized into numberOfCategories distinct
00193                                      rate categories for greater computational efficiency
00194                                      if you do a multiple analysis with  '-#' or '-N' but without bootstrapping the program
00195                                      will use GTRMIX instead
00196                     GTRGAMMA       : GTR + Optimization of substitution rates + GAMMA model of rate
00197                                      heterogeneity (alpha parameter will be estimated)
00198                     GTRMIX         : Inference of the tree under GTRCAT
00199                                      and thereafter evaluation of the final tree topology under GTRGAMMA
00200                     GTRCAT_GAMMA   : Inference of the tree with site-specific evolutionary rates.
00201                                      However, here rates are categorized using the 4 discrete GAMMA rates.
00202                                      Evaluation of the final tree topology under GTRGAMMA
00203                     GTRGAMMAI      : Same as GTRGAMMA, but with estimate of proportion of invariable sites
00204                     GTRMIXI        : Same as GTRMIX, but with estimate of proportion of invariable sites
00205                     GTRCAT_GAMMAI  : Same as GTRCAT_GAMMA, but with estimate of proportion of invariable sites
00206 
00207               AMINO ACIDS:
00208 
00209                     PROTCATmatrixName[F]        : specified AA matrix + Optimization of substitution rates + Optimization of site-specific
00210                                                   evolutionary rates which are categorized into numberOfCategories distinct
00211                                                   rate categories for greater computational efficiency
00212                                                   if you do a multiple analysis with  '-#' or '-N' but without bootstrapping the program
00213                                                   will use PROTMIX... instead
00214                     PROTGAMMAmatrixName[F]      : specified AA matrix + Optimization of substitution rates + GAMMA model of rate
00215                                                   heterogeneity (alpha parameter will be estimated)
00216                     PROTMIXmatrixName[F]        : Inference of the tree under specified AA matrix + CAT
00217                                                   and thereafter evaluation of the final tree topology under specified AA matrix + GAMMA
00218                     PROTCAT_GAMMAmatrixName[F]  : Inference of the tree under specified AA matrix and site-specific evolutionary rates.
00219                                                   However, here rates are categorized using the 4 discrete GAMMA rates.
00220                                                   Evaluation of the final tree topology under specified AA matrix + GAMMA
00221                     PROTGAMMAImatrixName[F]     : Same as PROTGAMMAmatrixName[F], but with estimate of proportion of invariable sites
00222                     PROTMIXImatrixName[F]       : Same as PROTMIXmatrixName[F], but with estimate of proportion of invariable sites
00223                     PROTCAT_GAMMAImatrixName[F] : Same as PROTCAT_GAMMAmatrixName[F], but with estimate of proportion of invariable sites
00224 
00225                 Available AA substitution models: DAYHOFF, DCMUT, JTT, MTREV, WAG, RTREV, CPREV, VT, BLOSUM62, MTMAM, GTR
00226                 With the optional 'F' appendix you can specify if you want to use empirical base frequencies
00227                 Please not that for mixed models you can in addition specify the per-gene AA model in
00228                 the mixed model file (see manual for details)
00229                 """,
00230                 equate=False,
00231                 ),
00232 
00233                 _Switch(['-M', 'partition_branch_lengths'],
00234                         "Switch on estimation of individual per-partition "
00235                         "branch lengths. Only has effect when used in "
00236                         "combination with 'partition_filename' ('-q'). "
00237                         "Branch lengths for individual partitions will be "
00238                         "printed to separate files.  A weighted average of the "
00239                         "branch lengths is computed by using the respective "
00240                         "partition lengths. "
00241                         ),
00242 
00243                 _Option(['-n', 'name'],
00244                         "Name used in the output files.",
00245                         filename=True,
00246                         equate=False,
00247                         ),
00248 
00249                 _Option(['-o', 'outgroup'],
00250                         "Name of a single outgroup or a comma-separated list "
00251                         "of outgroups, eg '-o Rat' or '-o Rat,Mouse'. In case "
00252                         "that multiple outgroups are not monophyletic the "
00253                         "first name in the list will be selected as outgroup. "
00254                         "Don't leave spaces between taxon names!",
00255                         checker_function=lambda x: len(x.split()) == 1,
00256                         equate=False,
00257                         ),
00258 
00259                 _Option(['-q', 'partition_filename'],
00260                         "File name containing the assignment of models to "
00261                         "alignment partitions for multiple models of "
00262                         "substitution. For the syntax of this file please "
00263                         "consult the RAxML manual.",
00264                         filename=True,
00265                         equate=False,
00266                         ),
00267 
00268                 _Option(['-p', 'parsimony_seed'],
00269                         "Random number seed for the parsimony inferences. "
00270                         "This allows you to reproduce your results and will "
00271                         "help developers debug the program. This option HAS "
00272                         "NO EFFECT in the parallel MPI version.",
00273                         equate=False,
00274                         ),
00275 
00276                 _Option(['-P', 'protein_model'],
00277                         "File name of a user-defined AA (Protein) substitution "
00278                         "model. This file must contain 420 entries, the first "
00279                         "400 being the AA substitution rates (this must be a "
00280                         "symmetric matrix) and the last 20 are the empirical "
00281                         "base frequencies.",
00282                         filename=True,
00283                         equate=False,
00284                         ),
00285 
00286                 _Option(['-r', 'binary_constraint'],
00287                         "File name of a binary constraint tree. "
00288                         "This tree does not need to be comprehensive, i.e. "
00289                         "contain all taxa.",
00290                         filename=True,
00291                         equate=False,
00292                         ),
00293 
00294                 _Option(['-s', 'sequences'],
00295                         "Name of the alignment data file, in PHYLIP format.",
00296                         filename=True,
00297                         equate=False,
00298                         ),
00299 
00300                 _Option(['-t', 'starting_tree'],
00301                         "File name of a user starting tree, in Newick format.",
00302                         filename=True,
00303                         equate=False,
00304                         ),
00305 
00306                 _Option(['-T', 'threads'],
00307                         "Number of threads to run. "
00308                         "PTHREADS VERSION ONLY! "
00309                         "Make sure to set this at most the number of CPUs "
00310                         "you have on your machine, otherwise, there will be "
00311                         "a huge performance decrease!",
00312                         equate=False,
00313                         ),
00314 
00315                 _Option(['-u', 'num_bootstrap_searches'],
00316                         "Number of multiple bootstrap searches per replicate. "
00317                         "Use this to obtain better ML trees for each "
00318                         "replicate. Default: 1 ML search per bootstrap "
00319                         "replicate.",
00320                         equate=False,
00321                         ),
00322 
00323                 _Switch(['-v', 'version'],
00324                         "Display version information."
00325                         ),
00326 
00327                 _Option(['-w', 'working_dir'],
00328                         "Name of the working directory where RAxML will "
00329                         "write its output files. Default: current directory.",
00330                         filename=True,
00331                         ),
00332 
00333                 _Option(['-x', 'rapid_bootstrap_seed'],
00334                         "Random seed for rapid bootstrapping.",
00335                         equate=False,
00336                         ),
00337 
00338                 _Switch(['-y', 'parsimony'],
00339                         "Only compute a parsimony starting tree, then exit."
00340                         ),
00341 
00342                 _Option(['-z', 'bipartition_filename'],
00343                         "Name of a file containing multiple trees, e.g. from "
00344                         "a bootstrap run, that shall be used to draw "
00345                         "bipartition values onto a tree provided with '-t'. "
00346                         "It can also be used to compute per-site log "
00347                         "likelihoods in combination with '-f g', and to read "
00348                         "a bunch of trees for a couple of other options "
00349                         "('-f h', '-f m', '-f n').",
00350                         filename=True,
00351                         equate=False,
00352                         ),
00353 
00354                 _Option(['-N', '-#', 'num_replicates'],
00355                     "Number of alternative runs on distinct starting trees. "
00356                     "In combination with the '-b' option, this will invoke a "
00357                     "multiple boostrap analysis. "
00358                     "DEFAULT: 1 single analysis."
00359                     "Note that '-N' has been added as an alternative since "
00360                     "'-#' sometimes caused problems with certain MPI job "
00361                     "submission systems, since '-#' is often used to start "
00362                     "comments. "
00363                     ,
00364                     equate=False,
00365                     ),
00366                 ]
00367         AbstractCommandline.__init__(self, cmd, **kwargs)
00368         # ENH: enforce -s, -n and -m
00369         if not self.parsimony_seed:
00370             self.parsimony_seed = 10000
00371 

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 44 of file _Raxml.py.

Definition at line 369 of file _Raxml.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: