[Biopython-dev] Bio.Application interface
Peter
biopython at maubp.freeserve.co.uk
Thu Apr 23 09:29:04 UTC 2009
On Wed, Apr 22, 2009 at 11:44 PM, Brad Chapman <chapmanb at 50mail.com> wrote:
> Peter and Cymon;
>
> My comment is: I think it is awesome MAFFT made up their own way
> of doing the command line.
Was that sarcasm Brad?
> Seriously, y'all are doing the right thing. Add a new class to
> Bio.Application: _OptionAlt or whatever you'd like to call MAFFT's
> inventive new way to specify command line arguments. Adapt the
> __str__ from _Option to do it the "--param val" way in this class.
> Then use this for your MAFFT commandline.
Maybe _DoubleDashOption for the class name? I haven't looked
at this closely enough to have a firm opinion - but as this will be a
private class anyway, the name doesn't matter so much.
> I believe I just summarized your discussion, so you can replace this
> whole message with +1.
:)
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
More information about the Biopython-dev
mailing list