1
# $Id: HSPFactory.pm,v 1.5 2003/01/22 22:33:51 jason Exp $
3
# BioPerl module for Bio::Search::HSP::HSPFactory
5
# Cared for by Jason Stajich <jason@bioperl.org>
7
# Copyright Jason Stajich
9
# You may distribute this module under the same terms as perl itself
11
# POD documentation - main docs before the code
15
Bio::Search::HSP::HSPFactory - A factory to create Bio::Search::HSP::HSPI objects
19
use Bio::Search::HSP::HSPFactory;
20
my $factory = new Bio::Search::HSP::HSPFactory();
21
my $resultobj = $factory->create(@args);
26
This is a general way of hiding the object creation process so that we
27
can dynamically change the objects that are created by the SearchIO
28
parser depending on what format report we are parsing.
30
This object is for creating new HSPs.
36
User feedback is an integral part of the evolution of this and other
37
Bioperl modules. Send your comments and suggestions preferably to
38
the Bioperl mailing list. Your participation is much appreciated.
40
bioperl-l@bioperl.org - General discussion
41
http://bioperl.org/MailList.shtml - About the mailing lists
45
Report bugs to the Bioperl bug tracking system to help us keep track
46
of the bugs and their resolution. Bug reports can be submitted via
49
bioperl-bugs@bioperl.org
50
http://bugzilla.bioperl.org/
52
=head1 AUTHOR - Jason Stajich
54
Email jason@bioperl.org
56
Describe contact details here
60
Additional contributors names and emails here
64
The rest of the documentation details each of the object methods.
65
Internal methods are usually preceded with a _
70
# Let the code begin...
73
package Bio::Search::HSP::HSPFactory;
74
use vars qw(@ISA $DEFAULT_TYPE);
78
use Bio::Factory::ObjectFactoryI;
80
@ISA = qw(Bio::Root::Root Bio::Factory::ObjectFactoryI );
83
$DEFAULT_TYPE = 'Bio::Search::HSP::GenericHSP';
89
Usage : my $obj = new Bio::Search::HSP::HSPFactory();
90
Function: Builds a new Bio::Search::HSP::HSPFactory object
91
Returns : Bio::Search::HSP::HSPFactory
98
my($class,@args) = @_;
100
my $self = $class->SUPER::new(@args);
101
my ($type) = $self->_rearrange([qw(TYPE)],@args);
102
$self->type($type) if defined $type;
109
Usage : $factory->create(%args)
110
Function: Create a new L<Bio::Search::HSP::HSPI> object
111
Returns : L<Bio::Search::HSP::HSPI>
112
Args : hash of initialization parameters
118
my ($self,@args) = @_;
119
my $type = $self->type;
120
eval { $self->_load_module($type) };
121
if( $@ ) { $self->throw("Unable to load module $type"); }
122
return $type->new(@args);
129
Usage : $factory->type('Bio::Search::HSP::GenericHSP');
130
Function: Get/Set the HSP creation type
132
Args : [optional] string to set
137
my ($self,$type) = @_;
138
if( defined $type ) {
139
# redundancy with the create method which also calls _load_module
140
# I know - but this is not a highly called object so I am going
142
eval {$self->_load_module($type) };
143
if( $@ ){ $self->warn("Cannot find module $type, unable to set type. $@") }
144
else { $self->{'_type'} = $type; }
146
return $self->{'_type'} || $DEFAULT_TYPE;