[Biopython-dev] Bio.Application interface

Cymon Cox cy at cymon.org
Fri Apr 24 11:31:28 EDT 2009


2009/4/24 Peter <biopython at maubp.freeserve.co.uk>

> >> > MAFFT uses "--param value" style options, and won't accept
> >> "--param=value"
> >> > or "-param value" as alternatives.
> >>
> >> OK.  Then yes, we should support that.  Brad, as Bio.Application is your
> >> module, would you like to comment?
> >>
> >> >
> >> > Neither use "-param=value", but if more applications it may turn up.
> >> >
> >>
> >> I don't think I have ever see a command line application that used that.
> >
> >
> > PRANK - Probabilistic Alignment Kit
> > http://www.ebi.ac.uk/goldman-srv/prank/prank/
> >
> > Advanced usage: 'prank [optional parameters] -d=sequence_file [optional
> > parameters]'
> >
> > Doesn't accept "-d sequence_file" or "- -d=sequence_file"
>
> I had misunderstood the quotes to be literally typed on the command line ;)


So the upshot is that both "- -param value" and "-param=value" need to be
supported.

Rather than add another variation on _Option, or alter _OptionAlt to cover
"-param=value", and as we only have a few command line interfaces at
present, I'd like to suggest the following simplification to _Option:

_AbstractParameter.__init__(:self, names = [], types = [], checker_function
= None,
                 is_required = 0, description = "", equate=True):

        self.names = names
        self.param_types = types
        self.checker_function = checker_function
        self.description = description
        self.is_required = is_required
        self.equate = equate

       [...]

class _Option(_AbstractParameter):
    """Represent an option that can be set for a program.

    This holds UNIXish options like:
    --append=yes
    --append yes
    --append
    -append=yes
    -a yes
    -append
    """
    def __str__(self):
        """Return the value of this option for the commandline.
        """
        output = "%s" % self.names[0]
        if self.value is not None:
            output += "%s%s " % \
                (self.equate and "=" or " ", self.value)
        return output

ie. add an equate flag

C.
--


More information about the Biopython-dev mailing list