Skip to content

Commit

Permalink
Switch types=["file"] to filename=True in app wrapper parameters (pri…
Browse files Browse the repository at this point in the history
…vate API change)
  • Loading branch information
peterjc committed Dec 7, 2010
1 parent 7a92530 commit fd99b97
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 117 deletions.
28 changes: 14 additions & 14 deletions Bio/Align/Applications/_Clustalw.py
Expand Up @@ -39,13 +39,13 @@ def __init__(self, cmd="clustalw", **kwargs):
[
_Option(["-infile", "-INFILE", "INFILE", "infile"],
"Input sequences.",
types=["file"]),
filename=True),
_Option(["-profile1", "-PROFILE1", "PROFILE1", "profile1"],
"Profiles (old alignment).",
types=["file"]),
filename=True),
_Option(["-profile2", "-PROFILE2", "PROFILE2", "profile2"],
"Profiles (old alignment).",
types=["file"]),
filename=True),
################## VERBS (do things) #############################
_Switch(["-options", "-OPTIONS", "OPTIONS", "options"],
"List the command line parameters"),
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, cmd="clustalw", **kwargs):
"Protein alignment with negative values in matrix"),
_Option(["-outfile", "-OUTFILE", "OUTFILE", "outfile"],
"Output sequence alignment file name",
types=["file"]),
filename=True),
_Option(["-output", "-OUTPUT", "OUTPUT", "output"],
"Output format: GCG, GDE, PHYLIP, PIR or NEXUS",
checker_function=lambda x: x in ["GCG", "GDE", "PHYLIP",
Expand Down Expand Up @@ -145,13 +145,13 @@ def __init__(self, cmd="clustalw", **kwargs):
"blosum", "pam",
"gonnet", "id"] or \
os.path.exists(x),
types=["file"]),
filename=True),
_Option(["-pwdnamatrix", "-PWDNAMATRIX", "PWDNAMATRIX", "pwdnamatrix"],
"DNA weight matrix=IUB, CLUSTALW or filename",
checker_function=lambda x: x in ["IUB", "CLUSTALW",
"iub", "clustalw"] or \
os.path.exists(x),
types=["file"]),
filename=True),
_Option(["-pwgapopen", "-PWGAPOPEN", "PWGAPOPEN", "pwgapopen"],
"Gap opening penalty",
checker_function=lambda x: isinstance(x, int) or \
Expand All @@ -163,25 +163,25 @@ def __init__(self, cmd="clustalw", **kwargs):
# ***Multiple Alignments:***
_Option(["-newtree", "-NEWTREE", "NEWTREE", "newtree"],
"Output file name for newly created guide tree",
types=["file"]),
filename=True),
_Option(["-usetree", "-USETREE", "USETREE", "usetree"],
"File name of guide tree",
checker_function=lambda x: os.path.exists,
types=["file"]),
filename=True),
_Option(["-matrix", "-MATRIX", "MATRIX", "matrix"],
"Protein weight matrix=BLOSUM, PAM, GONNET, ID or filename",
checker_function=lambda x: x in ["BLOSUM", "PAM",
"GONNET", "ID",
"blosum", "pam",
"gonnet", "id"] or \
os.path.exists(x),
types=["file"]),
filename=True),
_Option(["-dnamatrix", "-DNAMATRIX", "DNAMATRIX", "dnamatrix"],
"DNA weight matrix=IUB, CLUSTALW or filename",
checker_function=lambda x: x in ["IUB", "CLUSTALW",
"iub", "clustalw"] or \
os.path.exists(x),
types=["file"]),
filename=True),
_Option(["-gapopen", "-GAPOPEN", "GAPOPEN", "gapopen"],
"Gap opening penalty",
checker_function=lambda x: isinstance(x, int) or \
Expand Down Expand Up @@ -226,18 +226,18 @@ def __init__(self, cmd="clustalw", **kwargs):
"Merge two alignments by profile alignment"),
_Option(["-newtree1", "-NEWTREE1", "NEWTREE1", "newtree1"],
"Output file name for new guide tree of profile1",
types=["file"]),
filename=True),
_Option(["-newtree2", "-NEWTREE2", "NEWTREE2", "newtree2"],
"Output file for new guide tree of profile2",
types=["file"]),
filename=True),
_Option(["-usetree1", "-USETREE1", "USETREE1", "usetree1"],
"File name of guide tree for profile1",
checker_function=lambda x: os.path.exists,
types=["file"]),
filename=True),
_Option(["-usetree2", "-USETREE2", "USETREE2", "usetree2"],
"File name of guide tree for profile2",
checker_function=lambda x: os.path.exists,
types=["file"]),
filename=True),
# ***Sequence to Profile Alignments:***
_Switch(["-sequences", "-SEQUENCES", "SEQUENCES", "sequences"],
"Sequentially add profile2 sequences to profile1 alignment"),
Expand Down
2 changes: 1 addition & 1 deletion Bio/Align/Applications/_Dialign.py
Expand Up @@ -171,7 +171,7 @@ def __init__(self, cmd="dialign2-2", **kwargs):
"specified that are NOT considered for pairwise alignment"),
_Argument(["input"],
"Input file name. Must be FASTA format",
types=["file"],
filename=True,
is_required=True),
]
AbstractCommandline.__init__(self, cmd, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions Bio/Align/Applications/_Mafft.py
Expand Up @@ -260,7 +260,7 @@ def __init__(self, cmd="mafft", **kwargs):
"Transmembrane PAM number (Jones et al. 1994) "
"matrix is used. number>0. Default: BLOSUM62",
checker_function=os.path.exists,
types=["file"],
filename=True,
equate=False),
#Use a user-defined AA scoring matrix. The format of matrixfile is
#the same to that of BLAST. Ignored when nucleotide sequences are
Expand All @@ -269,7 +269,7 @@ def __init__(self, cmd="mafft", **kwargs):
"Use a user-defined AA scoring matrix. "
"Default: BLOSUM62",
checker_function=os.path.exists,
types=["file"],
filename=True,
equate=False),
#Incorporate the AA/nuc composition information into the scoring
#matrix. Default: off
Expand Down Expand Up @@ -314,7 +314,7 @@ def __init__(self, cmd="mafft", **kwargs):
"Seed alignments given in alignment_n (fasta format) "
"are aligned with sequences in input.",
checker_function=os.path.exists,
types=["file"],
filename=True,
equate=False),
#The old solution of also defining extra parameters with
#["--seed", "seed1"] etc worked, but clashes with the recent
Expand All @@ -328,15 +328,15 @@ def __init__(self, cmd="mafft", **kwargs):
_Argument(["input"],
"Input file name",
checker_function=os.path.exists,
types=["file"],
filename=True,
is_required=True),
###################################################################
#mafft-profile takes a second alignment input as an argument:
#mafft-profile align1 align2
_Argument(["input1"],
"Second input file name for the mafft-profile command",
checker_function=os.path.exists,
types=["file"]),
filename=True),
]
AbstractCommandline.__init__(self, cmd, **kwargs)

Expand Down
26 changes: 13 additions & 13 deletions Bio/Align/Applications/_Muscle.py
Expand Up @@ -51,23 +51,23 @@ def __init__(self, cmd="muscle", **kwargs):
#Can't use "in" as the final alias as this is a reserved word in python:
_Option(["-in", "in", "input"],
"Input filename",
types=["file"],
filename=True,
equate=False),
_Option(["-out", "out"],
"Output filename",
types=["file"],
filename=True,
equate=False),
_Switch(["-diags", "diags"],
"Find diagonals (faster for similar sequences)"),
_Switch(["-profile", "profile"],
"Perform a profile alignment"),
_Option(["-in1", "in1"],
"First input filename for profile alignment",
types=["file"],
filename=True,
equate=False),
_Option(["-in2", "in2"],
"Second input filename for a profile alignment",
types=["file"],
filename=True,
equate=False),
#anchorspacing Integer 32 Minimum spacing between
_Option(["-anchorspacing", "anchorspacing"],
Expand Down Expand Up @@ -149,13 +149,13 @@ def __init__(self, cmd="muscle", **kwargs):
# existing file).
_Option(["-log", "log"],
"Log file name",
types=["file"],
filename=True,
equate=False),
#loga File name None. Log file name (append
# to existing file).
_Option(["-loga", "loga"],
"Log file name (append to existing file)",
types=["file"],
filename=True,
equate=False),
#maxdiagbreak Integer 1 Maximum distance
# between two diagonals
Expand Down Expand Up @@ -349,31 +349,31 @@ def __init__(self, cmd="muscle", **kwargs):
################## Additional specified output files #########
_Option(["-phyiout", "phyiout"],
"Write PHYLIP interleaved output to specified filename",
types=["file"],
filename=True,
equate=False),
_Option(["-physout", "physout"],"Write PHYLIP sequential format to specified filename",
types=["file"],
filename=True,
equate=False),
_Option(["-htmlout", "htmlout"],"Write HTML output to specified filename",
types=["file"],
filename=True,
equate=False),
_Option(["-clwout", "clwout"],
"Write CLUSTALW output (with MUSCLE header) to specified "
"filename",
types=["file"],
filename=True,
equate=False),
_Option(["-clwstrictout", "clwstrictout"],
"Write CLUSTALW output (with version 1.81 header) to "
"specified filename",
types=["file"],
filename=True,
equate=False),
_Option(["-msfout", "msfout"],
"Write MSF format output to specified filename",
types=["file"],
filename=True,
equate=False),
_Option(["-fastaout", "fastaout"],
"Write FASTA format output to specified filename",
types=["file"],
filename=True,
equate=False),
############## END FORMATS ###################################
#anchors yes Use anchor optimization in tree dependent
Expand Down
6 changes: 3 additions & 3 deletions Bio/Align/Applications/_Prank.py
Expand Up @@ -49,11 +49,11 @@ def __init__(self, cmd="prank", **kwargs):
#-d=sequence_file
_Option(["-d", "d"],
"Input filename",
types=["file"],
filename=True,
is_required=True),
#-t=tree_file [default: no tree, generate approximate NJ tree]
_Option(["-t", "t"],"Input guide tree filename",
types=["file"]),
filename=True),
#-tree="tree_string" [tree in newick format; in double quotes]
_Option(["-tree", "tree"],
"Input guide tree as Newick string"),
Expand All @@ -66,7 +66,7 @@ def __init__(self, cmd="prank", **kwargs):
"Output filenames prefix. Default: 'output'\n "
"Will write: output.?.fas (depending on requested "
"format), output.?.xml and output.?.dnd",
types=["file"]),
filename=True),
#-f=output_format [default: 8]
_Option(["-f", "f"],
"Output alignment format. Default: 8 FASTA\n"
Expand Down
2 changes: 1 addition & 1 deletion Bio/Align/Applications/_Probcons.py
Expand Up @@ -101,7 +101,7 @@ def __init__(self, cmd="probcons", **kwargs):
_Argument(["input"],
"Input file name. Must be multiple FASTA alignment "+ \
"(MFA) format",
types=["file"],
filename=True,
is_required=True),
]
AbstractCommandline.__init__(self, cmd, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions Bio/Align/Applications/_TCoffee.py
Expand Up @@ -54,14 +54,14 @@ def __init__(self, cmd="t_coffee", **kwargs):
equate=False),
_Option(["-infile", "infile"],
"Specify the input file.",
types=["file"],
filename=True,
is_required=True,
equate=False),
#Indicates the name of the alignment output by t_coffee. If the
#default is used, the alignment is named <your sequences>.aln
_Option(["-outfile", "outfile"],
"Specify the output file. Default: <your sequences>.aln",
types=["file"],
filename=True,
equate=False),
_Switch(["-convert", "convert"],
"Specify you want to perform a file conversion"),
Expand Down
25 changes: 10 additions & 15 deletions Bio/Application/__init__.py
Expand Up @@ -467,11 +467,8 @@ class _Option(_AbstractParameter):
o description -- a description of the option.
o param_types -- a list of string describing the type of parameter,
which can help let programs know how to use it. The only supported
values for this are the empty list (default), and ['file'] which means
these argument values will automatically be escaped if the filename
contains spaces.
o filename -- True if this argument is a filename and should be
automatically quoted if it contains spaces.
o checker_function -- a reference to a function that will determine
if a given value is valid for this parameter. This function can either
Expand All @@ -487,14 +484,12 @@ class _Option(_AbstractParameter):
o value -- the value of a parameter
"""
def __init__(self, names, description, types=[], checker_function=None,
def __init__(self, names, description, filename=False, checker_function=None,
is_required=False, equate=True):
self.names = names
assert isinstance(description, basestring), \
"%r for %s" % (description, names[-1])
assert types == [] or types == ["file"], \
"%r for %s" % (types, names[0])
self.param_types = types
self.is_filename = filename
self.checker_function = checker_function
self.description = description
self.equate = equate
Expand All @@ -514,7 +509,7 @@ def __str__(self):
# now made explicitly when setting up the option.
if self.value is None:
return "%s " % self.names[0]
if "file" in self.param_types:
if self.is_filename:
v = _escape_filename(self.value)
else:
v = str(self.value)
Expand Down Expand Up @@ -563,14 +558,12 @@ def __str__(self):
class _Argument(_AbstractParameter):
"""Represent an argument on a commandline.
"""
def __init__(self, names, description, types=[], checker_function=None,
is_required=False):
def __init__(self, names, description, filename=False,
checker_function=None, is_required=False):
self.names = names
assert isinstance(description, basestring), \
"%r for %s" % (description, names[-1])
assert types == [] or types == ["file"], \
"%r for %s" % (types, names[0])
self.param_types = types
self.is_filename = filename
self.checker_function = checker_function
self.description = description
self.is_required = is_required
Expand All @@ -580,6 +573,8 @@ def __init__(self, names, description, types=[], checker_function=None,
def __str__(self):
if self.value is None:
return " "
elif self.is_filename:
return "%s " % _escape_filename(self.value)
else:
return "%s " % self.value

Expand Down

0 comments on commit fd99b97

Please sign in to comment.