Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.Align.Applications._Muscle.MuscleCommandline Class Reference
Inheritance diagram for Bio.Align.Applications._Muscle.MuscleCommandline:
Inheritance graph
[legend]
Collaboration diagram for Bio.Align.Applications._Muscle.MuscleCommandline:
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

Definition at line 12 of file _Muscle.py.


Constructor & Destructor Documentation

def Bio.Align.Applications._Muscle.MuscleCommandline.__init__ (   self,
  cmd = "muscle",
  kwargs 
)
Create a new instance of a command line wrapper object.

Reimplemented from Bio.Application.AbstractCommandline.

Definition at line 40 of file _Muscle.py.

00040 
00041     def __init__(self, cmd="muscle", **kwargs):
00042         CLUSTERING_ALGORITHMS   = ["upgma", "upgmb", "neighborjoining"]
00043         DISTANCE_MEASURES_ITER1 = ["kmer6_6", "kmer20_3", "kmer20_4", "kbit20_3",
00044                                    "kmer4_6"]
00045         DISTANCE_MEASURES_ITER2 = DISTANCE_MEASURES_ITER1 + \
00046                                   ["pctid_kimura", "pctid_log"]
00047         OBJECTIVE_SCORES        = ["sp", "ps", "dp", "xp", "spf", "spm"]
00048         TREE_ROOT_METHODS       = ["pseudo", "midlongestspan", "minavgleafdist"]
00049         SEQUENCE_TYPES          = ["protein", "nucleo", "auto"]
00050         WEIGHTING_SCHEMES       = ["none", "clustalw", "henikoff", "henikoffpb",
00051                                    "gsc", "threeway"]
00052         self.parameters = \
00053            [
00054             #Can't use "in" as the final alias as this is a reserved word in python:
00055             _Option(["-in", "in", "input"],
00056                     "Input filename",
00057                     filename=True,
00058                     equate=False),
00059             _Option(["-out", "out"],
00060                     "Output filename",
00061                     filename=True,
00062                     equate=False),
00063             _Switch(["-diags", "diags"],
00064                     "Find diagonals (faster for similar sequences)"),
00065             _Switch(["-profile", "profile"],
00066                     "Perform a profile alignment"),
00067             _Option(["-in1", "in1"],
00068                     "First input filename for profile alignment",
00069                     filename=True,
00070                     equate=False),
00071             _Option(["-in2", "in2"],
00072                     "Second input filename for a profile alignment",
00073                     filename=True,
00074                     equate=False),
00075             #anchorspacing   Integer              32                 Minimum spacing between
00076             _Option(["-anchorspacing", "anchorspacing"],
00077                     "Minimum spacing between anchor columns",
00078                     checker_function=lambda x: isinstance(x, int),
00079                     equate=False),
00080             #center          Floating point       [1]                Center parameter.
00081             #                                                        Should be negative.
00082             _Option(["-center", "center"],
00083                     "Center parameter - should be negative",
00084                     checker_function=lambda x: isinstance(x, float),
00085                     equate=False),
00086             #cluster1        upgma                upgmb              Clustering method.
00087             _Option(["-cluster1", "cluster1"],
00088                     "Clustering method used in iteration 1",
00089                     checker_function=lambda x: x in CLUSTERING_ALGORITHMS,
00090                     equate=False),
00091             #cluster2        upgmb                                   cluster1 is used in
00092             #                neighborjoining                         iteration 1 and 2,
00093             #                                                        cluster2 in later
00094             #                                                        iterations.
00095             _Option(["-cluster2", "cluster2"],
00096                     "Clustering method used in iteration 2",
00097                     checker_function=lambda x: x in CLUSTERING_ALGORITHMS,
00098                     equate=False),
00099             #diaglength      Integer              24                 Minimum length of
00100             #                                                        diagonal.
00101             _Option(["-diaglength", "diaglength"],
00102                     "Minimum length of diagonal",
00103                     checker_function=lambda x: isinstance(x, int),
00104                     equate=True),
00105             #diagmargin      Integer              5                  Discard this many
00106             #                                                        positions at ends of
00107             #                                                        diagonal.
00108             _Option(["-diagmargin", "diagmargin"],
00109                     "Discard this many positions at ends of diagonal",
00110                     checker_function=lambda x: isinstance(x, int),
00111                     equate=False),
00112             #distance1       kmer6_6              Kmer6_6 (amino) or Distance measure for
00113             #                kmer20_3             Kmer4_6 (nucleo)   iteration 1.
00114             #                kmer20_4
00115             #                kbit20_3
00116             #                kmer4_6
00117             _Option(["-distance1", "distance1"],
00118                     "Distance measure for iteration 1",
00119                     checker_function=lambda x: x in DISTANCE_MEASURES_ITER1,
00120                     equate=False),
00121             #distance2       kmer6_6              pctid_kimura       Distance measure for
00122             #                kmer20_3                                iterations 2, 3 ...
00123             #                kmer20_4
00124             #                kbit20_3
00125             #                pctid_kimura
00126             #                pctid_log
00127             _Option(["-distance2", "distance2"],
00128                     "Distance measure for iteration 2",
00129                     checker_function=lambda x: x in DISTANCE_MEASURES_ITER2,
00130                     equate=False),
00131             #gapopen         Floating point       [1]                The gap open score.
00132             #                                                        Must be negative.
00133             _Option(["-gapopen", "gapopen"],
00134                     "Gap open score - negative number",
00135                     checker_function=lambda x: isinstance(x, float),
00136                     equate=False),
00137             #hydro           Integer              5                  Window size for
00138             #                                                        determining whether a
00139             #                                                        region is hydrophobic.
00140             _Option(["-hydro", "hydro"],
00141                     "Window size for hydrophobic region",
00142                     checker_function=lambda x: isinstance(x, int),
00143                     equate=False),
00144             #hydrofactor     Floating point       1.2                Multiplier for gap
00145             #                                                        open/close penalties in
00146             #                                                        hydrophobic regions.
00147             _Option(["-hydrofactor", "hydrofactor"],
00148                     "Multiplier for gap penalties in hydrophobic regions",
00149                     checker_function=lambda x: isinstance(x, float),
00150                     equate=False),
00151             #log             File name            None.              Log file name (delete
00152             #                                                        existing file).
00153             _Option(["-log", "log"],
00154                     "Log file name",
00155                     filename=True,
00156                     equate=False),
00157             #loga            File name            None.              Log file name (append
00158             #                                                        to existing file).
00159             _Option(["-loga", "loga"],
00160                     "Log file name (append to existing file)",
00161                     filename=True,
00162                     equate=False),
00163             #maxdiagbreak    Integer              1                  Maximum distance
00164             #                                                        between two diagonals
00165             #                                                        that allows them to
00166             #                                                        merge into one
00167             #                                                        diagonal.
00168             _Option(["-maxdiagbreak", "maxdiagbreak"],
00169                     "Maximum distance between two diagonals that allows "
00170                     "them to merge into one diagonal",
00171                     checker_function=lambda x: isinstance(x, int),
00172                     equate=False),
00173             #maxhours        Floating point       None.              Maximum time to run in
00174             #                                                        hours. The actual time
00175             #                                                        may exceed the
00176             #                                                        requested limit by a
00177             #                                                        few minutes. Decimals
00178             #                                                        are allowed, so 1.5
00179             #                                                        means one hour and 30
00180             #                                                        minutes.
00181             _Option(["-maxhours", "maxhours"],
00182                     "Maximum time to run in hours",
00183                     checker_function=lambda x: isinstance(x, float),
00184                     equate=False),
00185             #maxiters        Integer 1, 2 ...     16                 Maximum number of
00186             #                                                        iterations.
00187             _Option(["-maxiters", "maxiters"],
00188                     "Maximum number of iterations",
00189                     checker_function=lambda x: isinstance(x, int),
00190                     equate=False),
00191             #maxtrees        Integer              1                  Maximum number of new
00192             #                                                        trees to build in
00193             #                                                        iteration 2.
00194             _Option(["-maxtrees", "maxtrees"],
00195                     "Maximum number of trees to build in iteration 2",
00196                     checker_function=lambda x: isinstance(x, int),
00197                     equate=False),
00198             #minbestcolscore Floating point       [1]                Minimum score a column
00199             #                                                        must have to be an
00200             #                                                        anchor.
00201             _Option(["-minbestcolscore", "minbestcolscore"],
00202                     "Minimum score a column must have to be an anchor",
00203                     checker_function=lambda x: isinstance(x, float),
00204                     equate=False),
00205             #minsmoothscore  Floating point       [1]                Minimum smoothed score
00206             #                                                        a column must have to
00207             #                                                        be an anchor.
00208             _Option(["-minsmoothscore", "minsmoothscore"],
00209                     "Minimum smoothed score a column must have to "
00210                     "be an anchor",
00211                     checker_function=lambda x: isinstance(x, float),
00212                     equate=False),
00213             #objscore        sp                   spm                Objective score used by
00214             #                ps                                      tree dependent
00215             #                dp                                      refinement.
00216             #                xp                                      sp=sum-of-pairs score.
00217             #                spf                                     spf=sum-of-pairs score
00218             #                spm                                     (dimer approximation)
00219             #                                                        spm=sp for < 100 seqs,
00220             #                                                        otherwise spf
00221             #                                                        dp=dynamic programming
00222             #                                                        score.
00223             #                                                        ps=average profile-
00224             #                                                        sequence score.
00225             #                                                        xp=cross profile score.
00226             _Option(["-objscore", "objscore"],
00227                     "Objective score used by tree dependent refinement",
00228                     checker_function=lambda x: x in OBJECTIVE_SCORES,
00229                     equate=False),
00230             #root1           pseudo               psuedo             Method used to root
00231             _Option(["-root1", "root1"],
00232                     "Method used to root tree in iteration 1",
00233                     checker_function=lambda x: x in TREE_ROOT_METHODS,
00234                     equate=False),
00235             #root2           midlongestspan                          tree; root1 is used in
00236             #                minavgleafdist                          iteration 1 and 2,
00237             #                                                        root2 in later
00238             #                                                        iterations.
00239             _Option(["-root2", "root2"],
00240                     "Method used to root tree in iteration 2",
00241                     checker_function=lambda x: x in TREE_ROOT_METHODS,
00242                     equate=False),
00243             #seqtype         protein              auto               Sequence type.
00244             #                nucleo
00245             #                auto
00246             _Option(["-seqtype", "seqtype"],
00247                     "Sequence type",
00248                     checker_function=lambda x: x in SEQUENCE_TYPES,
00249                     equate=False),
00250             #smoothscoreceil Floating point       [1]                Maximum value of column
00251             #                                                        score for smoothing
00252             #                                                        purposes.
00253             _Option(["-smoothscoreceil", "smoothscoreceil"],
00254                     "Maximum value of column score for smoothing",
00255                     checker_function=lambda x: isinstance(x, float),
00256                     equate=False),
00257             #smoothwindow    Integer              7                  Window used for anchor
00258             #                                                        column smoothing.
00259             _Option(["-smoothwindow", "smoothwindow"],
00260                     "Window used for anchor column smoothing",
00261                     checker_function=lambda x: isinstance(x, int),
00262                     equate=False),
00263             #SUEFF           Floating point value 0.1                Constant used in UPGMB
00264             #                between 0 and 1.                        clustering. Determines
00265             #                                                        the relative fraction
00266             #                                                        of average linkage
00267             #                                                        (SUEFF) vs. nearest-
00268             #                                                        neighbor linkage (1
00269             #                                                        SUEFF).
00270             _Option(["-sueff", "sueff"],
00271                     "Constant used in UPGMB clustering",
00272                     checker_function=lambda x: isinstance(x, float),
00273                     equate=False),
00274             #tree1           File name            None               Save tree produced in
00275             _Option(["-tree1", "tree1"],
00276                     "Save Newick tree from iteration 1",
00277                     equate=False),
00278             #tree2                                                   first or second
00279             #                                                        iteration to given file
00280             #                                                        in Newick (Phylip-
00281             #                                                        compatible) format.
00282             _Option(["-tree2", "tree2"],
00283                     "Save Newick tree from iteration 2",
00284                     equate=False),
00285             #weight1         none                 clustalw           Sequence weighting
00286             _Option(["-weight1", "weight1"],
00287                     "Weighting scheme used in iteration 1",
00288                     checker_function=lambda x: x in WEIGHTING_SCHEMES,
00289                     equate=False),
00290             #weight2         henikoff                                scheme.
00291             #                henikoffpb                              weight1 is used in
00292             #                gsc                                     iterations 1 and 2.
00293             #                clustalw                                weight2 is used for
00294             #                threeway                                tree-dependent
00295             #                                                        refinement.
00296             #                                                        none=all sequences have
00297             #                                                        equal weight.
00298             #                                                        henikoff=Henikoff &
00299             #                                                        Henikoff weighting
00300             #                                                        scheme.
00301             #                                                        henikoffpb=Modified
00302             #                                                        Henikoff scheme as used
00303             #                                                        in PSI-BLAST.
00304             #                                                        clustalw=CLUSTALW
00305             #                                                        method.
00306             #                                                        threeway=Gotoh three-
00307             #                                                        way method.
00308             _Option(["-weight2", "weight2"],
00309                     "Weighting scheme used in iteration 2",
00310                     checker_function=lambda x: x in WEIGHTING_SCHEMES,
00311                     equate=False),
00312             #################### FORMATS #######################################
00313             # Multiple formats can be specified on the command line
00314             # If -msf appears it will be used regardless of other formats
00315             # specified. If -clw appears (and not -msf), clustalw format will be
00316             # used regardless of other formats specified. If both -clw and
00317             # -clwstrict are specified -clwstrict will be used regardless of
00318             # other formats specified. If -fasta is specified and not -msf,
00319             # -clw, or clwstrict, fasta will be used. If -fasta and -html are
00320             # specified -fasta will be used. Only if -html is specified alone
00321             # will html be used. I kid ye not.
00322             #clw                no              Write output in CLUSTALW format (default is
00323             #                                   FASTA).
00324             _Switch(["-clw", "clw"],
00325                     "Write output in CLUSTALW format (with a MUSCLE header)"),
00326             #clwstrict          no              Write output in CLUSTALW format with the
00327             #                                   "CLUSTAL W (1.81)" header rather than the
00328             #                                   MUSCLE version. This is useful when a post-
00329             #                                   processing step is picky about the file
00330             #                                   header.
00331             _Switch(["-clwstrict", "clwstrict"],
00332                     "Write output in CLUSTALW format with version 1.81 header"),
00333             #fasta              yes             Write output in FASTA format. Alternatives
00334             #                                   include clw,
00335             #                                   clwstrict, msf and html.
00336             _Switch(["-fasta", "fasta"],
00337                     "Write output in FASTA format"),
00338             #html               no              Write output in HTML format (default is
00339             #                                   FASTA).
00340             _Switch(["-html", "html"],
00341                     "Write output in HTML format"),
00342             #msf                no              Write output in MSF format (default is
00343             #                                   FASTA).
00344             _Switch(["-msf", "msf"],
00345                     "Write output in MSF format"),
00346             #Phylip interleaved - undocumented as of 3.7
00347             _Switch(["-phyi", "phyi"],
00348                     "Write output in PHYLIP interleaved format"),
00349             #Phylip sequential - undocumented as of 3.7
00350             _Switch(["-phys", "phys"],
00351                     "Write output in PHYLIP sequential format"),
00352             ################## Additional specified output files #########
00353             _Option(["-phyiout", "phyiout"],
00354                     "Write PHYLIP interleaved output to specified filename",
00355                     filename=True,
00356                     equate=False),
00357             _Option(["-physout", "physout"],"Write PHYLIP sequential format to specified filename",
00358                     filename=True,
00359                     equate=False),
00360             _Option(["-htmlout", "htmlout"],"Write HTML output to specified filename",
00361                     filename=True,
00362                     equate=False),
00363             _Option(["-clwout", "clwout"],
00364                     "Write CLUSTALW output (with MUSCLE header) to specified "
00365                     "filename",
00366                     filename=True,
00367                     equate=False),
00368             _Option(["-clwstrictout", "clwstrictout"],
00369                     "Write CLUSTALW output (with version 1.81 header) to "
00370                     "specified filename",
00371                     filename=True,
00372                     equate=False),
00373             _Option(["-msfout", "msfout"],
00374                     "Write MSF format output to specified filename",
00375                     filename=True,
00376                     equate=False),
00377             _Option(["-fastaout", "fastaout"],
00378                     "Write FASTA format output to specified filename",
00379                     filename=True,
00380                     equate=False),
00381             ############## END FORMATS ###################################
00382             #anchors            yes             Use anchor optimization in tree dependent
00383             #                                   refinement iterations.
00384             _Switch(["-anchors", "anchors"],
00385                     "Use anchor optimisation in tree dependent "
00386                     "refinement iterations"),
00387             #noanchors          no              Disable anchor optimization. Default is
00388             #                                   anchors.
00389             _Switch(["-noanchors", "noanchors"],
00390                     "Do not use anchor optimisation in tree dependent "
00391                     "refinement iterations"),
00392             #group              yes             Group similar sequences together in the
00393             #                                   output. This is the default. See also
00394             #                                   stable.
00395             _Switch(["-group", "group"],
00396                     "Group similar sequences in output"),
00397             #stable             no              Preserve input order of sequences in output
00398             #                                   file. Default is to group sequences by
00399             #                                   similarity (group).
00400             _Switch(["-stable", "stable"],
00401                     "Do not group similar sequences in output (not supported in v3.8)"),
00402             ############## log-expectation profile score ######################
00403             # One of either -le, -sp, or -sv
00404             #
00405             # According to the doc, spn is default and the only option for
00406             # nucleotides: this doesnt appear to be true. -le, -sp, and -sv can
00407             # be used and produce numerically different logs (what is going on?)
00408             #
00409             #spn fails on proteins
00410             #le                 maybe           Use log-expectation profile score (VTML240).
00411             #                                    Alternatives are to use sp or sv. This is
00412             #                                    the default for amino acid sequences.
00413             _Switch(["-le", "le"],
00414                     "Use log-expectation profile score (VTML240)"),
00415             #sv                 no              Use sum-of-pairs profile score (VTML240).
00416             #                                   Default is le.
00417             _Switch(["-sv", "sv"],
00418                     "Use sum-of-pairs profile score (VTML240)"),
00419             #sp                 no              Use sum-of-pairs protein profile score
00420             #                                   (PAM200). Default is le.
00421             _Switch(["-sp", "sp"],
00422                     "Use sum-of-pairs protein profile score (PAM200)"),
00423             #spn                maybe           Use sum-of-pairs nucleotide profile score
00424             #                                   (BLASTZ parameters). This is the only option
00425             #                                   for nucleotides, and is therefore the
00426             #                                   default.
00427             _Switch(["-spn", "spn"],
00428                     "Use sum-of-pairs protein nucleotide profile score"),
00429             ############## END log-expectation profile score ######################
00430             #quiet              no              Do not display progress messages.
00431             _Switch(["-quiet", "quiet"],
00432                     "Use sum-of-pairs protein nucleotide profile score"),
00433             #refine             no              Input file is already aligned, skip first
00434             #                                   two iterations and begin tree dependent
00435             #                                   refinement.
00436             _Switch(["-refine", "refine"],
00437                     "Only do tree dependent refinement"),
00438             #core               yes in muscle,  Do not catch exceptions.
00439             #                   no in muscled.
00440             _Switch(["-core", "core"],
00441                     "Catch exceptions"),
00442             #nocore             no in muscle,   Catch exceptions and give an error message
00443             #                   yes in muscled. if possible.
00444             _Switch(["-nocore", "nocore"],
00445                     "Do not catch exceptions"),
00446             #termgapsfull       no              Terminal gaps penalized with full penalty.
00447             #                                   [1] Not fully supported in this version.
00448             #
00449             #termgapshalf       yes             Terminal gaps penalized with half penalty.
00450             #                                   [1] Not fully supported in this version.
00451             #
00452             #termgapshalflonger no              Terminal gaps penalized with half penalty if
00453             #                                   gap relative to
00454             #                                   longer sequence, otherwise with full
00455             #                                   penalty.
00456             #                                   [1] Not fully supported in this version.
00457             #verbose            no              Write parameter settings and progress
00458             #                                   messages to log file.
00459             _Switch(["-verbose", "verbose"],
00460                     "Write parameter settings and progress"),
00461             #version            no              Write version string to stdout and exit.
00462             _Switch(["-version", "version"],
00463                     "Write version string to stdout and exit"),
00464            ]
00465         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 51 of file _Muscle.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: