wrapper for Perl scripts within EMBOSS
Peter Ernst
P.Ernst at dkfz-heidelberg.de
Thu Jul 17 14:27:27 UTC 2003
On Thu, 17 Jul 2003, Derek Gatherer wrote:
> So the following would presumably be the simplest possible wrapper, just
> opening and running a Perl script, using a single line ACD file just to
> name the program and nothing else.
I think I am missing the point in this strategy.
What is the advantage of having a C-Emboss wrapper around a Perl
program, if you do not use any of the ACD features (eg. reading
sequences)?
Also, something like "-help" on the command-line will lead embInit()
to dump senseless information.
> However, the Perl script then needs to prompt for any further
> parameters, infiles etc.
Yes, because embInit() doesn't know about it.
> This works, but is it against the EMBOSS philosophy? I did try
> collecting the Perl parameters via the ACD, but didn't manage to
> figure out a way of easily manipulating them into the command line
> (ie. ajSystemEnv( &cmd, env) ).
The question is here what you really want?
If you don't want Emboss/ACD to interfere with your command-line, you
better avoid calling embInit(). :-)
However, if you want ACD to do some part of the job for you, then one
has to define, what part of the work you want to leave for ACD, and
what you want to do yourself in your Perl program. An example:
If one of the input parameters is supposed to be an input sequence,
what do you want to have?
1. The sequence as string (in what format)?
2. The filename (what to do with DB entries?) ?
What to do with defaults evaluated by ACD?
In fact I see 2 strategies:
A.) ignore ACD
B.) use ACD to work on the command-line, read in sequences, do
prompting, etc...
But then you have the problem to access the information ACD has
collected. For exactly this purpose, there are the set of
ajAcdGet....() functions in Emboss.
Here is an example, how to use these functions in Perl to get
the input sequence as a Perl-string from ACD:
test1.acd:
----------
appl: test1 [
doc: "test1 Perl script"
]
sequence: sequence [
param: "Y"
req: "Y"
]
test1.pl:
---------
#!/usr/bin/perl
# --- import all EMBOSS functions into this namespace
use Bio::Emboss qw(:all);
# --- store script and acd file in the same directory
($thisdir = $0) =~ s:[^/]*$::;
$thisdir = "." unless length ($thisdir);
$ENV{"EMBOSS_ACDROOT"} = $thisdir;
embInitPerl("test1", \@ARGV);
my $seqstr = ajAcdGetSeq("sequence")->ajSeqChar();
print $seqstr;
usage:
------
% perl test1.pl swissprot:edd_rat
test1 Perl script
ARRERMTAREEASLRTLEGRRRATLLSARQGMMSARGDFLNYALSLMRSHNDEHSDVLPVLDVCSLK...
or
% perl test1.pl
test1 Perl script
Input sequence: swissprot:edd_rat
ARRERMTAREEASLRTLEGRRRATLLSARQGMMSARGDFLNYALSLMRSHNDEHSDVLPVL....
and
% perl test1.pl -help
Mandatory qualifiers:
[-sequence] sequence (no help text) sequence value
Optional qualifiers: (none)
Advanced qualifiers: (none)
General qualifiers:
-help boolean Report command line options. More
information on associated and general
qualifiers can be found with -help -verbose
Kind regards,
Peter Ernst
--
=======================================================================
Peter Ernst
Department of Molecular Biophysics - B020
Deutsches Krebsforschungszentrum (German Cancer Research Center) DKFZ
Im Neuenheimer Feld 580 / Technologiepark 3
69120 Heidelberg, Germany phone: +49-6221-42-2330
http://genome.dkfz-heidelberg.de/ fax: +49-6221-42-2333
=======================================================================
>
> #--------------ACD file, hello.acd--------------------------------------#
>
> appl: hello [
> doc: "Calls a Perl script which then does the rest of what you
> want to do"
> ]
>
> #--------------hello.c wrapper to call hello.pl-----------------------#
>
> #include "emboss.h"
>
> int main(int argc, char **argv, char **env)
> {
> AjPStr cmd=NULL;
>
> char *prog_default = "perl -w path/to/bin/hello.pl";
>
> embInit("hello",argc,argv);
>
> // invoke the command
>
> if (!ajNamGetValueC("perl -w path/to/bin/hello.pl", &cmd))
> cmd = ajStrNewC(prog_default);
>
> ajFmtError( "..%s..\n\n", ajStrStr( cmd));
> ajDebug( "Executing '%S'\n", cmd);
> ajSystemEnv( &cmd, env);
>
> ajExit();
>
> return 0;
> }
More information about the EMBOSS
mailing list