[Biopython-dev] Changing the details of the app wrapper private API

Peter biopython at maubp.freeserve.co.uk
Fri Dec 3 16:04:07 UTC 2010


Hi all,

For those of you that have used the Bio.Application wrapper
classes, I'd like comments on this proposed change:

https://github.com/peterjc/biopython/commit/a1f160dea719add408eade99026f84a2af4447c2

The idea is that typically each command line tool parameter
(switch, option or argument) must have a name (which in
the current implication is a list of strings and this covers both
the name used in Python and for switches and options the
text used for the command), and should have a description
(used for the docstring).

What the patch does is swap the __init__ arg order round
to make name and description mandatory. As a consequence,
I had to go and change every single usage - which all used
the order. I made them use the keyword approach for other
arguments (helpful for searching for argument usage).

The good news is that for a typical option (where the defaults
make sense, e.g. use the equals sign) we would have:

_Option(["-sformat","sformat"], "Input sequence(s) format (e.g. fasta,
genbank)")

rather than:

_Option(["-sformat","sformat"], [], None, 0, "Input sequence(s) format
(e.g. fasta, genbank)")

I'm also tempted to shorten the is_required option to just
required, and perhaps checker_function to validator?
Its a small thing, but given I want to change the (private)
API anyway this is a good time to do it (if ever).

Related to this, I'd like to replace the types argument, which
is now just used as [] (default) or ["file"], with a boolean to
control automatic quoting of filename arguments. Previously
this list could also include "input" and "output" which were
used by the now removed ApplicationResult class. Assuming
the proposed patch is merged, we can do this with a simple
search and replace of types=["file"] with the new name, e.g.
auto_quote=True or similar. Alternatively, perhaps this should
be handled with a new subclass of _Option, say _FileOption?

[In the medium/long term, I'm wondering if we can drop
the set_parameter method, and then do everything via
conventional Python properties, perhaps with decorators
for flagging things like mandatory arguments.]

Regards,

Peter



More information about the Biopython-dev mailing list