3 # BioPerl module for Bio::Search::Result::ResultFactory
5 # Please direct questions and support issues to <bioperl-l@bioperl.org>
7 # Cared for by Jason Stajich <jason@bioperl.org>
9 # Copyright Jason Stajich
11 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Search::Result::ResultFactory - A factory to create Bio::Search::Result::ResultI objects
21 use Bio::Search::Result::ResultFactory;
22 my $factory = Bio::Search::Result::ResultFactory->new();
23 my $resultobj = $factory->create(@args);
27 This is a general way of hiding the object creation process so that we
28 can dynamically change the objects that are created by the SearchIO
29 parser depending on what format report we are parsing.
31 This object is for creating new Results.
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to
39 the Bioperl mailing list. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 Please direct usage questions or support issues to the mailing list:
48 L<bioperl-l@bioperl.org>
50 rather than to the module maintainer directly. Many experienced and
51 reponsive experts will be able look at the problem and quickly
52 address it. Please include a thorough description of the problem
53 with code and data examples if at all possible.
57 Report bugs to the Bioperl bug tracking system to help us keep track
58 of the bugs and their resolution. Bug reports can be submitted via the
61 http://bugzilla.open-bio.org/
63 =head1 AUTHOR - Jason Stajich
65 Email jason@bioperl.org
69 The rest of the documentation details each of the object methods.
70 Internal methods are usually preceded with a _
75 # Let the code begin...
78 package Bio
::Search
::Result
::ResultFactory
;
79 use vars
qw($DEFAULT_TYPE);
83 use base qw(Bio::Root::Root Bio::Factory::ObjectFactoryI);
86 $DEFAULT_TYPE = 'Bio::Search::Result::GenericResult';
92 Usage : my $obj = Bio::Search::Result::ResultFactory->new();
93 Function: Builds a new Bio::Search::Result::ResultFactory object
94 Returns : Bio::Search::Result::ResultFactory
101 my($class,@args) = @_;
103 my $self = $class->SUPER::new
(@args);
104 my ($type) = $self->_rearrange([qw(TYPE)],@args);
105 $self->type($type) if defined $type;
112 Usage : $factory->create(%args)
113 Function: Create a new L<Bio::Search::Result::ResultI> object
114 Returns : L<Bio::Search::Result::ResultI>
115 Args : hash of initialization parameters
121 my ($self,@args) = @_;
122 my $type = $self->type;
123 eval { $self->_load_module($type) };
124 if( $@
) { $self->throw("Unable to load module $type: $@"); }
125 return $type->new(@args);
132 Usage : $factory->type('Bio::Search::Result::GenericResult');
133 Function: Get/Set the Result creation type
135 Args : [optional] string to set
141 my ($self,$type) = @_;
142 if( defined $type ) {
143 # redundancy with the create method which also calls _load_module
144 # I know - but this is not a highly called object so I am going
146 eval {$self->_load_module($type) };
147 if( $@
){ $self->warn("Cannot find module $type, unable to set type"); }
148 else { $self->{'_type'} = $type; }
150 return $self->{'_type'} || $DEFAULT_TYPE;