2 # BioPerl module for Bio::Tools::Run::AnalysisFactory
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Martin Senger <martin.senger@gmail.com>
7 # For copyright and disclaimer see below.
10 # POD documentation - main docs before the code
14 Bio::Tools::Run::AnalysisFactory - A directory of analysis tools
18 # list all available analyses from the default location,
19 # using a default (SOAP) access method
20 use Bio::Tools::Run::AnalysisFactory;
21 my $list = Bio::Tools::Run::AnalysisFactory->new();
23 use Data::Dumper; print Dumper ($list);
25 # ditto, but from a different location
26 use Bio::Tools::Run::AnalysisFactory;
28 Bio::Tools::Run::AnalysisFactory->new(-location => 'http://somewhere/something')
31 # ...and using a different access method
32 # (this example is not yet impelmented)
33 use Bio::Tools::Run::AnalysisFactory;
35 Bio::Tools::Run::AnalysisFactory->new(-location => 'http://somewhere/something',
39 # list available categories of analyses
40 use Bio::Tools::Run::AnalysisFactory;
42 Bio::Tools::Run::AnalysisFactory->new();
43 ->available_categories;
44 use Data::Dumper; print Dumper ($categories);
46 # show all analyses group by categories
47 use Bio::Tools::Run::AnalysisFactory;
48 my $factory = Bio::Tools::Run::AnalysisFactory->new();
49 foreach $cat ( @{ $factory->available_categories } ) {
50 my @sublist = @{ $factory->available_analyses ($cat) };
52 join ("\n\t", @{ $factory->available_analyses ($cat) }),
56 # create an analysis object
57 use Bio::Tools::Run::AnalysisFactory;
58 $service = Bio::Tools::Run::AnalysisFactory->new();
59 ->create_analysis ('edit.seqret');
66 The module represents a list of available analysis tools from a given
67 location using a given access method. Additionally, for any of the
68 available analyses, it can create an object of type C<Bio::Tools::Run::Analysis>.
70 The module is a higher-level abstraction whose main job is to load a
71 'real-work-doing' implementation. Which one is used, it depends on the
72 C<-access> parameter. The same design is used here as for
73 C<Bio::Tools::Run::Analysis> module.
75 There is available a I<SOAP> access to almost all EMBOSS applications,
76 running at European Bioinformatics Institute.
78 The documentation of all C<public> methods are to be found
79 in C<Bio::Factory::AnalysisI>.
85 User feedback is an integral part of the evolution of this and other
86 Bioperl modules. Send your comments and suggestions preferably to
87 the Bioperl mailing list. Your participation is much appreciated.
89 bioperl-l@bioperl.org - General discussion
90 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
94 Please direct usage questions or support issues to the mailing list:
96 I<bioperl-l@bioperl.org>
98 rather than to the module maintainer directly. Many experienced and
99 reponsive experts will be able look at the problem and quickly
100 address it. Please include a thorough description of the problem
101 with code and data examples if at all possible.
103 =head2 Reporting Bugs
105 Report bugs to the Bioperl bug tracking system to help us keep track
106 of the bugs and their resolution. Bug reports can be submitted via the
109 http://redmine.open-bio.org/projects/bioperl/
113 Martin Senger (martin.senger@gmail.com)
117 Copyright (c) 2003, Martin Senger and EMBL-EBI.
120 This module is free software; you can redistribute it and/or modify
121 it under the same terms as Perl itself.
125 This software is provided "as is" without warranty of any kind.
133 http://www.ebi.ac.uk/soaplab/Perl_Client.html
139 Here is the rest of the object methods. Internal methods are preceded
140 with an underscore _.
145 # Let the code begin...
147 package Bio
::Tools
::Run
::AnalysisFactory
;
148 use vars
qw(@ISA $Revision);
152 use Bio::Factory::AnalysisI;
153 @ISA = qw(Bio::Root::Root Bio::Factory::AnalysisI);
160 # -----------------------------------------------------------------------------
162 # Available (understood) parameters:
164 # (+ parameters used in guessing an access)
166 # -----------------------------------------------------------------------------
170 Usage : my $factory =
171 Bio::Tools::Run::AnalysisFactory->new(-access => 'soap',
172 -location => 'http://...');
173 Returns : a new Bio::Tools::Run::AnalysisFactory object representing a list
174 of available analyses
175 Args : There may be additional arguments which are specific
176 to the access method (see methods 'new' or '_initialize'
177 of the access-specific implementations (such as module
178 Bio::Tools::Run::AnalysisFactory::soap for a SOAP-based access).
180 The recognised and used arguments are:
186 It builds, populates and returns a new C<Bio::Tools::Run::AnalysisFactory> object. This
187 is how it is seen from the outside. But in fact, it builds, populates
188 and returns a more specific lower-level object, for example
189 C<Bio::Tools::Run::AnalysisFactory::soap> object - which one it is it depends on the C<-access>
196 It indicates what lower-level module to load. Default is 'soap'.
197 Other (but future) possibilities are:
204 A location of the service. The contents is access-specific (see
205 details in the lower-level implementation modules).
207 Default is C<http://www.ebi.ac.uk/soaplab/services> (there are
208 services running at European Bioinformatics Institute on top of most
209 of EMBOSS analyses, and on some others).
213 In addition to the I<location> parameter, you may need to specify also
214 a location/URL of an HTTP proxy server (if your site requires
215 one). The expected format is C<http://server:port>. There is no
216 default value. It is also an access-specific parameter which may not
217 be used by all access methods.
221 For long(er) running jobs the HTTP connection may be time-outed. In
222 order to avoid it (or, vice-versa, to call timeout sooner) you may
223 specify C<timeout> with the number of seconds the connection will be
224 kept alive. Zero means to keep it alive forever. The default value is
232 my ($caller,@args) = @_;
233 my $class = ref($caller) || $caller;
235 if ($class eq 'Bio::Tools::Run::AnalysisFactory') {
237 # this is called only the first time when somebody calls: 'new
238 # Bio::Tools::Run::AnalysisFactory (...)', and it actually loads a
239 # 'real-work-doing' module and call this new() method again
240 # (unless the loaded module has its own new() method)
243 @param { map { lc $_ } keys %param } = values %param; # lowercase keys
245 $param {'-access'} || # use -access parameter
246 $class->_guess_access ( \
%param ) || # or guess from other parameters
247 'soap'; # or use a default access method
248 $access = "\L$access"; # normalize capitalization to lower case
250 # remember the access method (putting it into @args means that the
251 # object - when created - will remember it)
252 push (@args, (-access
=> $access)) unless $param {'-access'};
254 # load module with the real implementation - as defined in $access
255 return undef unless (&_load_access_module
($access));
257 # this calls this same method new() - but now its object part
258 # (see the upper branche above) is called
259 return "Bio::Tools::Run::AnalysisFactory::$access"->new (@args);
263 # if $caller is an object, or if it is an underlying
264 # 'real-work-doing' class (e.g. Bio::Tools::Run::AnalysisFactory::soap)
265 # then we want to call SUPER to create and bless a new object
267 my ($self) = $class->SUPER::new
(@args);
269 # now the $self is an empty object - we will populate it from
270 # the $caller - if $caller is an object (so we do cloning here)
273 %{ $self } = %{ $caller };
276 # and finally add values from '@args' into the newly created
277 # object (the values will overwrite the values copied above);
278 # this is done by calling '_initialize' of the 'real-work-doing'
279 # class (if there is no one there, there is always an empty one
280 # in Bio::Root::Root)
282 $self->_initialize (@args);
288 # -----------------------------------------------------------------------------
290 =head2 _load_access_module
292 Usage : $class->_load_access_module ($access)
293 Returns : 1 on success, undef on failure
294 Args : 'access' should contain the last part of the
295 name of a module who does the real implementation
297 It does (in the run-time) a similar thing as
299 require Bio::Tools::Run::AnalysisFactory::$access
301 It prints an error on STDERR if it fails to find and load the module
302 (for example, because of the compilation errors in the module).
306 sub _load_access_module
{
309 my $load = "Bio/Tools/Run/AnalysisFactory/$access.pm";
315 Bio
::Root
::Root
->throw (<<END);
316 $load: $access cannot be found or loaded
318 For more information about the Analysis system please see the Bio::Tools::Run::AnalysisFactory docs.
326 # -----------------------------------------------------------------------------
330 Usage : $class->_guess_access ($rh_params)
331 Returns : string with a guessed access protocol (e.g. 'soap'),
332 or undef if the guessing failed
333 Args : 'rh_params' is a hash reference containing parameters given
336 It makes an expert guess what kind of access/transport protocol should
337 be used to access the underlying analysis. The guess is based on the
338 parameters in I<rh_params>. Rememeber that this method is called only
339 if there was no I<-access> parameter which could tell directly what
340 access method to use.
345 my ($class, $rh_params) = @_;
349 # -----------------------------------------------------------------------------
351 =head2 VERSION and Revision
353 Usage : print $Bio::Tools::Run::AnalysisFactory::VERSION;
354 print $Bio::Tools::Run::AnalysisFactory::Revision;