[Biopython-dev] _Switch and _Option questions

Peter biopython at maubp.freeserve.co.uk
Sun Apr 11 10:11:37 UTC 2010


On Sun, Apr 11, 2010 at 6:01 AM, Vincent Davis <vincent at vincentdavis.net> wrote:
> I am just getting started with class AbstractCommandline(object): The first
> set of questions is more about questions I had after reading the
> documentation.

Keep in mind that the documentation there is is more aimed at the
end user, rather than a developer writing a new command line wrapper.
There are also some "historical" bits which we are phasing out still
(like the deprecated ApplicationResult class) which add confusion.

> First questions/comment mostly about documentation:
> It appears that not all attributes need to be set in _Options and _Switch,
> for example
>    _Switch: o is_set -- if the parameter has been set, I don't see and
> example of this being specified in a  _Switch self.parameter statement. I
> see that it defaults to False, Is there a case that this is set in a
> self.parameters statement? I think I understand this. It is just documented
> as though it should be specified.

Switches are either true or false, meaning either appended to the command
line string or not. This boolean is held in the is_set parameter. They don't
take values (see _Option for that).

> If I don't need a checker_function in _Options then I must use an None, I
> guess as a place holder?

I think so from memory.

> Not clear if equate should be used as  "equate" or 0,1, by this I mean it is
> not documented well
>   same goes for is_required

They should be interpreted as booleans, so for new code using True
and False is clearer, but 1 and 0 are also fine (and used in a lot of
the older code).

> Looks like Value is similar to is_set in that it is not ever specified in a
> self.Parameters statement

No, the user specifies the value if they want to use that option.

> I don't think the example using Bio.Emboss.Applications import
> WaterCommandline includes the use of a _switch

They do - all the EMBOSS wrapps have common switches
like auto, stdout etc defined in the base class.

> ---------
> Second set of questions
> For both of the next questions I am mostly asking if the
> feature/functionality is part of the class AbstractCommandline(object):
>
> If two _Switches are mutually exclusive in there use is there a way to make
> sure that they not both specified? Example anywhere?

This isn't supported in Bio.Application explicitly, but can be done
as in Bio.Blast.Applications (see the _validate methods). Do you
really need to do this? You could just leave it to the user.

> Basically same question for _Option, How do I refer to the value of another
> _option.

Just like an end user would, via the property it defines. See the
Bio.Blast.Applications examples.

Peter




More information about the Biopython-dev mailing list