[Biopython-dev] Bio.Application interface
Cymon Cox
cy at cymon.org
Thu Apr 23 14:32:10 UTC 2009
2009/4/22 Brad Chapman <chapmanb at 50mail.com>
> Peter and Cymon;
>
> > >> This might be a silly question, but do you actually these exact option
> > >> layouts for MUSCLE and MAFFT? Many Unix tools use something like
> > >> libopt and will actually take slight variations, and may also offer
> short
> > >> and long names for the same option. Perhaps the existing option code
> > >> in Bio.Application will suffice?
> > >
> > > 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?
>
> My comment is: I think it is awesome MAFFT made up their own way
> of doing the command line.
I think you'll be likewise inspired by the MUSCLE command line parsing:
[cymon at chara mafft]$ muscle -in Tests/Fasta/f002 -anchorspacing -cluster1
upgmb
Command-line option "upgmb" must start with '-'
But of course, these two are perfectly acceptable:
[cymon at chara mafft]$ muscle -in Tests/Fasta/f002 -anchorspacing
--cluster1=upgmb
[cymon at chara mafft]$ muscle -in Tests/Fasta/f002 -anchorspacing
on-balance-I-think-Ill-go-home -cluster1 upgmb
At present, there is no current way to force a value argument to an option
so cmd.set_parameter("-anchorspacing") is acceptable in the interface. But,
in general, I assume the idea is not 'save' the user from niceties of the
particular programme command line, ie in command line interface I'm allowing
users to set parameters which either dont work or crash the programme...
> 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.
class _OptionAlt(_AbstractParameter):
"""Represent an option that can be set for a program.
This holds UNIXish options like:
--append yes
--append
"""
def __str__(self):
"""Return the value of this option for the commandline.
"""
if self.names[0].find("--") >= 0:
output = "%s" % self.names[0]
if self.value is not None:
output += " %s " % self.value
else:
output += " "
else:
raise ValueError("Unrecognized option type: %s" % self.names[0])
return output
C.
--
____________________________________________________________________
Cymon J. Cox
Centro de Ciencias do Mar
Faculdade de Ciencias do Mar e Ambiente (FCMA)
Universidade do Algarve
Campus de Gambelas
8005-139 Faro
Portugal
Phone: +0351 289800909 ext 7909
Fax: +0351 289800051
Email: cy at cymon.org, cymon at ualg.pt, cymon.cox at gmail.com
HomePage : http://biology.duke.edu/bryology/cymon.html
-8.63/-6.77
More information about the Biopython-dev
mailing list