comparison variant_effect_predictor/Bio/Search/HSP/HSPFactory.pm @ 0:1f6dce3d34e0

Uploaded
author mahtabm
date Thu, 11 Apr 2013 02:01:53 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1f6dce3d34e0
1 # $Id: HSPFactory.pm,v 1.4 2002/10/22 07:45:17 lapp Exp $
2 #
3 # BioPerl module for Bio::Search::HSP::HSPFactory
4 #
5 # Cared for by Jason Stajich <jason@bioperl.org>
6 #
7 # Copyright Jason Stajich
8 #
9 # You may distribute this module under the same terms as perl itself
10
11 # POD documentation - main docs before the code
12
13 =head1 NAME
14
15 Bio::Search::HSP::HSPFactory - A factory to create Bio::Search::HSP::HSPI objects
16
17 =head1 SYNOPSIS
18
19 use Bio::Search::HSP::HSPFactory;
20 my $factory = new Bio::Search::HSP::HSPFactory();
21 my $resultobj = $factory->create(@args);
22
23 =head1 DESCRIPTION
24
25
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.
29
30 This object is for creating new HSPs.
31
32 =head1 FEEDBACK
33
34 =head2 Mailing Lists
35
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.
39
40 bioperl-l@bioperl.org - General discussion
41 http://bioperl.org/MailList.shtml - About the mailing lists
42
43 =head2 Reporting Bugs
44
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
47 email or the web:
48
49 bioperl-bugs@bioperl.org
50 http://bugzilla.bioperl.org/
51
52 =head1 AUTHOR - Jason Stajich
53
54 Email jason@bioperl.org
55
56 Describe contact details here
57
58 =head1 CONTRIBUTORS
59
60 Additional contributors names and emails here
61
62 =head1 APPENDIX
63
64 The rest of the documentation details each of the object methods.
65 Internal methods are usually preceded with a _
66
67 =cut
68
69
70 # Let the code begin...
71
72
73 package Bio::Search::HSP::HSPFactory;
74 use vars qw(@ISA $DEFAULT_TYPE);
75 use strict;
76
77 use Bio::Root::Root;
78 use Bio::Factory::ObjectFactoryI;
79
80 @ISA = qw(Bio::Root::Root Bio::Factory::ObjectFactoryI );
81
82 BEGIN {
83 $DEFAULT_TYPE = 'Bio::Search::HSP::GenericHSP';
84 }
85
86 =head2 new
87
88 Title : new
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
92 Args :
93
94
95 =cut
96
97 sub new {
98 my($class,@args) = @_;
99
100 my $self = $class->SUPER::new(@args);
101 my ($type) = $self->_rearrange([qw(TYPE)],@args);
102 $self->type($type) if defined $type;
103 return $self;
104 }
105
106 =head2 create
107
108 Title : create
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
113
114
115 =cut
116
117 sub create{
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);
123 }
124
125
126 =head2 type
127
128 Title : type
129 Usage : $factory->type('Bio::Search::HSP::GenericHSP');
130 Function: Get/Set the HSP creation type
131 Returns : string
132 Args : [optional] string to set
133
134 =cut
135
136 sub type{
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
141 # to leave it in
142 eval {$self->_load_module($type) };
143 if( $@ ){ $self->warn("Cannot find module $type, unable to set type") }
144 else { $self->{'_type'} = $type; }
145 }
146 return $self->{'_type'} || $DEFAULT_TYPE;
147 }
148
149 1;