[Biopython-dev] Properties in Bio.Application interface?

Peter biopython at maubp.freeserve.co.uk
Sun Apr 26 12:46:55 UTC 2009


On Thu, Apr 23, 2009 at 10:29 AM, Peter <biopython at maubp.freeserve.co.uk> wrote:
> What about this bit I wrote earlier:
>>> ... 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
>>> valid argument names in python may not overlap with the valid
>>> parameter names.
>
> We'll have to see how well the above idea works in practice - it
> may not be general enough to be useful.
>
> Also, perhaps we can automatically generate properties for each
> argument allowing this:
>
> cmd.input = "sample.fa"
>
> rather than:
>
> cmd.set_parameter("input", "sample.fa")
>
> For the "switch" type arguments which take no value, if these are
> implemented with a separate option class (maybe _Switch or
> _OptionNoValue) then rather than:
>
> cmd.set_parameter("noanchors")
>
> we might want to do:
>
> cmd.noanchors = True
>
> and allow the switch to be removed with:
>
> cmd.noanchors = False
>
> i.e. For those arguments which take no argument (is "switch" the
> right term here?), evaluate the property set value as a boolean to
> add/remove -noanchors from the command line string.
>
> I think using properties in this way could make the command line
> object more intuitive, but again python puts limits on property names
> which might mean for some arguments you'd have to use the
> set_parameter version.
>
> Peter
>

I have cleaning up the existing Bio.Application command line objects
in CVS to follow the parameter alias convention already laid out in
Bio.Application.  i.e. They all now have human readable paramater
aliases, which are also valid python identifiers.  This means these
"human readable names" can also be used for argument names in __init__
(using **kwargs), or as property names.

I think I've got properties working now as an experiment on my
machine, generated at run time using the "human readable name" for
each parameter.  We would need to special case "switch" arguments
(i.e. those which take no value) as outlined above.

Does this sound worthwhile?  If so, I'll put together an enhancement
bug with a patch, or a branch on github.

Peter



More information about the Biopython-dev mailing list