Bio::Tools::Analysis
SimpleAnalysisBase
Summary
Bio::Tools::Analysis::SimpleAnalysisBase - abstact superclass for
SimpleAnalysis implementations
Package variables
Privates (from "my" definitions)
$FLOAT = '[+-]?\d*\.\d*'
%STATUS = map { $_ => 1 } qw(CREATED COMPLETED TERMINATED_BY_ERROR)
Included modules
Inherit
Synopsis
Description
This class is a generic implementation of SimpleAnalysisI and should
be used as a base class for specific implementations.
SimpleAnalysis implementing modules just need to provide a specific _run()
result() and _init() methods, plus any get/set methods for parameter
to the analysis program.
Methods
Methods description
Usage : $job->new(...)
Returns : a new analysis object,
Args : none (but an implementation may choose
to add arguments representing parameters for the analysis
program. Each key value of must have a method implemented
for it in a subclass. A seq () method is provided here as
this will probably be needed by all sequence analysis programs |
Usage : $job->seq()
Returns : a Bio::PrimarySeqI implementing sequence object, or void
Args : None, or a Bio::PrimarySeqI implementing object |
Useage : $analysis->analysis_name();
Returns : The analysis name
Arguments: none |
Useage : $analysis->analysis_spec();
Returns : a hash reference to a hash of analysis parameters. See
Bio::SimpleAnalysisI for a list of recommended key values.
Arguments: none |
Usage :$analysis->clear();
Returns :true value on success
Arguments :none
Purpose :to remove raw results from a previous analysis so that
an analysis can be repeated with different parameters. |
Useage : $analysis->input_spec();
Returns : a reference to an array of hashes of analysis parameters. See
Bio::SimpleAnalysisI for a list of recommended key values.
Arguments: none |
Useage : $analysis->result_spec();
Returns : a reference to a hashes of resultformats. See
Bio::SimpleAnalysisI for a list of recommended key values. The key
values can be used as parameters to the result() method, the values
provide descriptions.
Arguments: none |
Methods code
sub new
{ my $class = shift;
my $self = $class->SUPER::new(); $self->_init; while ( @_ ) {
my $key = lc shift;
$key =~ s/^-//;
$self->$key(shift);
}
return $self;} |
sub seq
{ my ($self,$value) = @_;
if ( defined $value) {
$self->throw("I need a Bio::PrimarySeqI, not [". $value. "]")
unless $value->isa('Bio::PrimarySeqI');
$self->throw(" I need a PrimarySeq object, not a BioSeq object ")
if $value->isa('Bio::SeqI');
my $mol_type = $self->analysis_spec->{'type'};
$self->throw("I need a [" . $mol_type . "] seq, not a [". $value->alphabet. "]")
unless $value->alphabet =~/$mol_type/i;
$self->{'_seq'} = $value;
return $self;
}
return $self->{'_seq'} ;} |
sub analysis_name
{ my $self = shift;
return $self->{'_ANALYSIS_NAME'};} |
sub analysis_spec
{ my $self = shift;
return $self->{'_ANALYSIS_SPEC'};} |
sub clear
{ my $self= shift;
if (defined($self->{'_result'})) {
delete $self->{'_result'};
}
if (defined ($self->{'_parsed'})) {
delete $self->{'_parsed'};
}
return 1;} |
sub input_spec
{ my $self = shift;
return $self->{'_INPUT_SPEC'};} |
sub result_spec
{ my $self = shift;
return $self->{'_RESULT_SPEC'};} |
sub run
{ my ($self, $args) = @_;
$self->_process_arguments ($args) if $args;
$self->throw("Need a sequence object as an input") unless $self->seq;
$self->debug(Data::Dumper->Dump([$self],[$self]));
$self->_run;
return $self;} |
sub wait_for
{ my ($self, $args) = @_;
$self->run($args);} |
sub status
{ my ($self,$value) = @_;
if( defined $value) {
no strict 'refs';
my $class = ref($self);
$self->throw("Not a valid status value [$value]\n".
"Valid values are ". join(", ", keys %STATUS ))
unless defined $STATUS{$value};
$self->{'_status'} = $value;
use strict;
}
return $self->{'_status'} || 'CREATED' ;} |
sub _process_arguments
{ my ($self, $args) = @_;
my %spec;
map {$spec{ $_->{'name'} } = $_ } @{$self->input_spec};
$self->debug(Data::Dumper->Dump([\%spec, $args],[\%spec, $args]));
foreach my $key (keys %$args) {
my $value = $args->{$key};
$self->throw("Unknown argument [$key]")
unless $spec{$key};
$self->$key($value);
}
foreach my $key (keys %spec) {
$self->throw("Mandatory argument [$key] is not set")
if $spec{$key}{'mandatory'} eq 'true' and not defined $self->$key;
}} |
sub _run
{ shift->throw_not_implemented(); } |
General documentation
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to one
of the Bioperl mailing lists. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bio.perl.org/MailList.html - About the mailing lists
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
bioperl-bugs@bio.perl.org
http://bugzilla.bioperl.org/
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _