2 # BioPerl module for Bio::Search::Result::ResultFactory
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason@bioperl.org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Search::Result::ResultFactory - A factory to create Bio::Search::Result::ResultI objects
20 use Bio::Search::Result::ResultFactory;
21 my $factory = Bio::Search::Result::ResultFactory->new();
22 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 Results.
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/wiki/Mailing_lists - About the mailing lists
45 Please direct usage questions or support issues to the mailing list:
47 I<bioperl-l@bioperl.org>
49 rather than to the module maintainer directly. Many experienced and
50 reponsive experts will be able look at the problem and quickly
51 address it. Please include a thorough description of the problem
52 with code and data examples if at all possible.
56 Report bugs to the Bioperl bug tracking system to help us keep track
57 of the bugs and their resolution. Bug reports can be submitted via the
60 https://github.com/bioperl/bioperl-live/issues
62 =head1 AUTHOR - Jason Stajich
64 Email jason@bioperl.org
68 The rest of the documentation details each of the object methods.
69 Internal methods are usually preceded with a _
74 # Let the code begin...
77 package Bio
::Search
::Result
::ResultFactory
;
78 use vars
qw($DEFAULT_TYPE);
82 use base qw(Bio::Root::Root Bio::Factory::ObjectFactoryI);
85 $DEFAULT_TYPE = 'Bio::Search::Result::GenericResult';
91 Usage : my $obj = Bio::Search::Result::ResultFactory->new();
92 Function: Builds a new Bio::Search::Result::ResultFactory object
93 Returns : Bio::Search::Result::ResultFactory
100 my($class,@args) = @_;
102 my $self = $class->SUPER::new
(@args);
103 my ($type) = $self->_rearrange([qw(TYPE)],@args);
104 $self->type($type) if defined $type;
111 Usage : $factory->create(%args)
112 Function: Create a new L<Bio::Search::Result::ResultI> object
113 Returns : L<Bio::Search::Result::ResultI>
114 Args : hash of initialization parameters
120 my ($self,@args) = @_;
121 my $type = $self->type;
122 eval { $self->_load_module($type) };
123 if( $@
) { $self->throw("Unable to load module $type: $@"); }
124 return $type->new(@args);
131 Usage : $factory->type('Bio::Search::Result::GenericResult');
132 Function: Get/Set the Result creation type
134 Args : [optional] string to set
140 my ($self,$type) = @_;
141 if( defined $type ) {
142 # redundancy with the create method which also calls _load_module
143 # I know - but this is not a highly called object so I am going
145 eval {$self->_load_module($type) };
146 if( $@
){ $self->warn("Cannot find module $type, unable to set type"); }
147 else { $self->{'_type'} = $type; }
149 return $self->{'_type'} || $DEFAULT_TYPE;