3 # BioPerl module for Bio::Search::Hit::HitFactory
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::Hit::HitFactory - A factory to create Bio::Search::Hit::HitI objects
19 use Bio::Search::Hit::HitFactory;
20 my $factory = new Bio::Search::Hit::HitFactory();
21 my $resultobj = $factory->create(@args);
25 This is a general way of hiding the object creation process so that we
26 can dynamically change the objects that are created by the SearchIO
27 parser depending on what format report we are parsing.
29 This object is for creating new Hits.
35 User feedback is an integral part of the evolution of this and other
36 Bioperl modules. Send your comments and suggestions preferably to
37 the Bioperl mailing list. Your participation is much appreciated.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/MailList.shtml - About the mailing lists
44 Report bugs to the Bioperl bug tracking system to help us keep track
45 of the bugs and their resolution. Bug reports can be submitted via
48 bioperl-bugs@bioperl.org
49 http://bugzilla.bioperl.org/
51 =head1 AUTHOR - Jason Stajich
53 Email jason@bioperl.org
55 Describe contact details here
59 Additional contributors names and emails here
63 The rest of the documentation details each of the object methods.
64 Internal methods are usually preceded with a _
69 # Let the code begin...
72 package Bio
::Search
::Hit
::HitFactory
;
73 use vars
qw(@ISA $DEFAULT_TYPE);
77 use Bio::Factory::ObjectFactoryI;
79 @ISA = qw(Bio::Root::Root Bio::Factory::ObjectFactoryI );
82 $DEFAULT_TYPE = 'Bio::Search::Hit::GenericHit';
88 Usage : my $obj = new Bio::Search::Hit::HitFactory();
89 Function: Builds a new Bio::Search::Hit::HitFactory object
90 Returns : Bio::Search::Hit::HitFactory
97 my($class,@args) = @_;
99 my $self = $class->SUPER::new
(@args);
100 my ($type) = $self->_rearrange([qw(TYPE)],@args);
101 $self->type($type) if defined $type;
108 Usage : $factory->create(%args)
109 Function: Create a new L<Bio::Search::Hit::HitI> object
110 Returns : L<Bio::Search::Hit::HitI>
111 Args : hash of initialization parameters
117 my ($self,@args) = @_;
118 my $type = $self->type;
119 eval { $self->_load_module($type) };
120 if( $@
) { $self->throw("Unable to load module $type"); }
121 return $type->new(@args);
128 Usage : $factory->type('Bio::Search::Hit::GenericHit');
129 Function: Get/Set the Hit creation type
131 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;