2 # BioPerl module for Bio::Tools::Analysis::SimpleAnalysisBase
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Heikki Lehvaslaiho <heikki-at-bioperl-dot-org>
8 # Copyright Richard Adams
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::Analysis::SimpleAnalysisBase - abstract superclass for
17 SimpleAnalysis implementations
21 # not to be run directly
25 This class is a generic implementation of SimpleAnalysisI and should
26 be used as a base class for specific implementations.
28 Modules implementing SimpleAnalysisBase only need to provide specific
29 _init(), _run() and result() methods, plus any get/set methods for
30 parameters to the analysis program.
34 L<Bio::SimpleAnalysisI>,
41 User feedback is an integral part of the evolution of this and other
42 Bioperl modules. Send your comments and suggestions preferably to one
43 of the Bioperl mailing lists. Your participation is much appreciated.
45 bioperl-l@bioperl.org - General discussion
46 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
50 Please direct usage questions or support issues to the mailing list:
52 I<bioperl-l@bioperl.org>
54 rather than to the module maintainer directly. Many experienced and
55 reponsive experts will be able look at the problem and quickly
56 address it. Please include a thorough description of the problem
57 with code and data examples if at all possible.
61 Report bugs to the Bioperl bug tracking system to help us keep track
62 the bugs and their resolution. Bug reports can be submitted via the
65 https://github.com/bioperl/bioperl-live/issues
69 Richard Adams, Richard.Adams@ed.ac.uk,
70 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
74 The rest of the documentation details each of the object
75 methods. Internal methods are usually preceded with a _
80 # Let the code begin...
83 package Bio
::Tools
::Analysis
::SimpleAnalysisBase
;
88 my $FLOAT = '[+-]?\d*\.\d*';
90 my %STATUS = map { $_ => 1 } qw(CREATED COMPLETED TERMINATED_BY_ERROR);
92 use base
qw(Bio::WebAgent Bio::SimpleAnalysisI);
96 Usage : $job->new(...)
97 Returns : a new analysis object,
98 Args : none (but an implementation may choose
99 to add arguments representing parameters for the analysis
100 program. Each key value of must have a method implemented
101 for it in a subclass. A seq () method is provided here as
102 this will probably be needed by all sequence analysis programs
109 my $self = $class->SUPER::new
(); #WebAgent new
110 $self->_init; #this line has to be before the attributes are filled in
122 Returns : a Bio::PrimarySeqI implementing sequence object, or void
123 Args : None, or a Bio::PrimarySeqI implementing object
128 my ($self,$value) = @_;
129 if ( defined $value) {
130 $self->throw("I need a Bio::PrimarySeqI, not [". $value. "]")
131 unless $value->isa('Bio::PrimarySeqI');
132 $self->throw(" I need a PrimarySeq object, not a BioSeq object ")
133 if $value->isa('Bio::SeqI');
135 my $mol_type = $self->analysis_spec->{'type'};
136 $self->throw("I need a [" . $mol_type . "] seq, not a [". $value->alphabet. "]")
137 unless $value->alphabet =~/$mol_type/i;
138 $self->{'_seq'} = $value;
141 return $self->{'_seq'} ;
146 Usage : $analysis->analysis_name();
147 Returns : The analysis name
154 return $self->{'_ANALYSIS_NAME'};
159 Usage : $analysis->analysis_spec();
160 Returns : a hash reference to a hash of analysis parameters. See
161 Bio::SimpleAnalysisI for a list of recommended key values.
168 return $self->{'_ANALYSIS_SPEC'};
173 Usage : $analysis->clear();
174 Returns : true value on success
176 Purpose : to remove raw results from a previous analysis so that
177 an analysis can be repeated with different parameters.
183 if (defined($self->{'_result'})) {
184 delete $self->{'_result'};
186 if (defined ($self->{'_parsed'})) {
187 delete $self->{'_parsed'};
196 Usage : $analysis->input_spec();
197 Returns : a reference to an array of hashes of analysis parameters. See
198 Bio::SimpleAnalysisI for a list of recommended key values.
205 return $self->{'_INPUT_SPEC'};
210 Usage : $analysis->result_spec();
211 Returns : a reference to a hashes of resultformats. See
212 Bio::SimpleAnalysisI for a list of recommended key values.
213 The key values can be used as parameters to the result()
214 method, the values provide descriptions.
221 return $self->{'_RESULT_SPEC'};
225 my ($self, $args) = @_;
226 $self->_process_arguments ($args) if $args;
229 $self->throw("Need a sequence object as an input") unless $self->seq;
230 $self->debug(Data
::Dumper
->Dump([$self],[$self]));
238 my ($self, $args) = @_;
243 my ($self,$value) = @_;
245 if( defined $value) {
247 my $class = ref($self);
248 $self->throw("Not a valid status value [$value]\n".
249 "Valid values are ". join(", ", keys %STATUS ))
250 unless defined $STATUS{$value};
251 $self->{'_status'} = $value;
254 return $self->{'_status'} || 'CREATED' ;
257 sub _process_arguments
{
258 my ($self, $args) = @_;
261 map {$spec{ $_->{'name'} } = $_ } @
{$self->input_spec};
263 $self->debug(Data
::Dumper
->Dump([\
%spec, $args],[\
%spec, $args]));
264 foreach my $key (keys %$args) {
265 my $value = $args->{$key};
267 $self->throw("Unknown argument [$key]")
272 foreach my $key (keys %spec) {
273 $self->throw("Mandatory argument [$key] is not set")
274 if $spec{$key}{'mandatory'} eq 'true' and not defined $self->$key;
279 sub _run
{ shift->throw_not_implemented();}