1
# $Id: SimpleAnalysisBase.pm,v 1.5 2003/09/23 13:50:37 radams Exp $
3
# BioPerl module for Bio::Tools::Analysis::SimpleAnalysisBase
5
# Cared for by Heikki Lehvaslaiho <heikki@ebi.ac.uk>
7
# Copyright Richard Adams
9
# You may distribute this module under the same terms as perl itself
11
# POD documentation - main docs before the code
15
Bio::Tools::Analysis::SimpleAnalysisBase - abstact superclass for
16
SimpleAnalysis implementations
20
# no to be run directly
24
This class is a generic implementation of SimpleAnalysisI and should
25
be used as a base class for specific implementations.
27
SimpleAnalysis implementing modules just need to provide a specific _run()
28
result() and _init() methods, plus any get/set methods for parameter
29
to the analysis program.
33
L<Bio::SimpleAnalysisI>,
40
User feedback is an integral part of the evolution of this and other
41
Bioperl modules. Send your comments and suggestions preferably to one
42
of the Bioperl mailing lists. Your participation is much appreciated.
44
bioperl-l@bioperl.org - General discussion
45
http://bio.perl.org/MailList.html - About the mailing lists
49
Report bugs to the Bioperl bug tracking system to help us keep track
50
the bugs and their resolution. Bug reports can be submitted via email
53
bioperl-bugs@bio.perl.org
54
http://bugzilla.bioperl.org/
58
Richard Adams, Richard.Adams@ed.ac.uk,
59
Heikki Lehvaslaiho, heikki@ebi.ac.uk
63
The rest of the documentation details each of the object
64
methods. Internal methods are usually preceded with a _
69
# Let the code begin...
72
package Bio::Tools::Analysis::SimpleAnalysisBase;
77
use Bio::SimpleAnalysisI;
80
my $FLOAT = '[+-]?\d*\.\d*';
82
my %STATUS = map { $_ => 1 } qw(CREATED COMPLETED TERMINATED_BY_ERROR);
84
@ISA = qw(Bio::WebAgent Bio::SimpleAnalysisI );
88
Usage : $job->new(...)
89
Returns : a new analysis object,
90
Args : none (but an implementation may choose
91
to add arguments representing parameters for the analysis
92
program. Each key value of must have a method implemented
93
for it in a subclass. A seq () method is provided here as
94
this will probably be needed by all sequence analysis programs
101
my $self = $class->SUPER::new(); #WebAGent new
102
$self->_init; #this line has to be before the attributes are filled in
114
Returns : a Bio::PrimarySeqI implementing sequence object, or void
115
Args : None, or a Bio::PrimarySeqI implementing object
120
my ($self,$value) = @_;
121
if ( defined $value) {
122
$self->throw("I need a Bio::PrimarySeqI, not [". $value. "]")
123
unless $value->isa('Bio::PrimarySeqI');
124
$self->throw(" I need a PrimarySeq object, not a BioSeq object ")
125
if $value->isa('Bio::SeqI');
127
my $mol_type = $self->analysis_spec->{'type'};
128
$self->throw("I need a [" . $mol_type . "] seq, not a [". $value->alphabet. "]")
129
unless $value->alphabet =~/$mol_type/i;
130
$self->{'_seq'} = $value;
133
return $self->{'_seq'} ;
138
Useage : $analysis->analysis_name();
139
Returns : The analysis name
146
return $self->{'_ANALYSIS_NAME'};
151
Useage : $analysis->analysis_spec();
152
Returns : a hash reference to a hash of analysis parameters. See
153
Bio::SimpleAnalysisI for a list of recommended key values.
160
return $self->{'_ANALYSIS_SPEC'};
165
Usage :$analysis->clear();
166
Returns :true value on success
168
Purpose :to remove raw results from a previous analysis so that
169
an analysis can be repeated with different parameters.
175
if (defined($self->{'_result'})) {
176
delete $self->{'_result'};
178
if (defined ($self->{'_parsed'})) {
179
delete $self->{'_parsed'};
188
Useage : $analysis->input_spec();
189
Returns : a reference to an array of hashes of analysis parameters. See
190
Bio::SimpleAnalysisI for a list of recommended key values.
197
return $self->{'_INPUT_SPEC'};
202
Useage : $analysis->result_spec();
203
Returns : a reference to a hashes of resultformats. See
204
Bio::SimpleAnalysisI for a list of recommended key values. The key
205
values can be used as parameters to the result() method, the values
206
provide descriptions.
213
return $self->{'_RESULT_SPEC'};
217
my ($self, $args) = @_;
218
$self->_process_arguments ($args) if $args;
221
$self->throw("Need a sequence object as an input") unless $self->seq;
222
$self->debug(Data::Dumper->Dump([$self],[$self]));
230
my ($self, $args) = @_;
235
my ($self,$value) = @_;
237
if( defined $value) {
239
my $class = ref($self);
240
$self->throw("Not a valid status value [$value]\n".
241
"Valid values are ". join(", ", keys %STATUS ))
242
unless defined $STATUS{$value};
243
$self->{'_status'} = $value;
246
return $self->{'_status'} || 'CREATED' ;
249
sub _process_arguments {
250
my ($self, $args) = @_;
253
map {$spec{ $_->{'name'} } = $_ } @{$self->input_spec};
255
$self->debug(Data::Dumper->Dump([\%spec, $args],[\%spec, $args]));
256
foreach my $key (keys %$args) {
257
my $value = $args->{$key};
259
$self->throw("Unknown argument [$key]")
264
foreach my $key (keys %spec) {
265
$self->throw("Mandatory argument [$key] is not set")
266
if $spec{$key}{'mandatory'} eq 'true' and not defined $self->$key;
271
sub _run { shift->throw_not_implemented();}