[Biopython-dev] Bio.Application interface
Peter
biopython at maubp.freeserve.co.uk
Wed Apr 22 06:26:11 EDT 2009
On Wed, Apr 22, 2009 at 10:48 AM, Cymon Cox <cy at cymon.org> wrote:
> From reading the previous discussion on the list, I gather there is a
> preference for removing helper functions to the Bio.Application command line
> interfaces, such that the user interface would be something like:
>
> from Bio import Application
> from Bio.Align.Applications import MafftCommandline
> cmd = MafftCommandline()
> cmd.set_parameter("input", "sample.fa")
> [etc...]
> i, o, e = Application.generic_run(cmd)
>
> ie the user explicitly sets the cl parameters.
Yes, that would fit my preference for giving the user direct access to
the command line as a string, to invoke as they choose. We might
want to discuss extending the AbstractCommandline __init__ method
to take **kwargs, allowing the parameters to be set like this:
from Bio import Application
from Bio.Align.Applications import MafftCommandline
cmd = MafftCommandline(input="sample.fa", ...)
return_code, std_handle, err_handle = Application.generic_run(cmd)
I'm not sure how well this would work in practice as the range of
validate argument names in python may not overlap with the valid
parameter names.
> Ive written Application.AbstractCommandline for both MUSCLE and MAFFT.
> However, each of these programmes uses a variation on the parameter styles
> not easily covered by the current _AbstractParameter classes _Option and
> _Argument. The _Option class deals with parameters of the type "-
> -append=yes" and "-a yes", ...
> A muscle command might be:
> "muscle -in Fasta/f002 -out Fasta/temp_align_out2.fa -objscore sp
> -noanchors"
> ie with a "-noanchors" command
Those kind of options which don't take a value are really common on
Unix, I suspect we already have things like this in the other wrappers.
I'd guess they just use the _Option class and omit the value.
> So, it looks like a _OptionNoEquals parameter class is required to cover the
> "- -param value", and I would suggest a _ArgumentName class that returns the
> parameter name to the command line such that:
>
> cmd.set_parameter("- -nofit") returns "- -nofit" to the cl, and
> cmd.set_parameter("- -nofit", value) raises and error via the
> checker_function
You are right, a subclass of _Option which checks there is no value argument
could be sensible. Maybe _OptionNoValue rather than _OptionNoEquals?
Peter
More information about the Biopython-dev
mailing list