2 # BioPerl module for Bio::Cluster::ClusterFactory
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Hilmar Lapp <hlapp at gmx.net>
8 # Copyright Hilmar Lapp
10 # You may distribute this module under the same terms as perl itself
13 # (c) Hilmar Lapp, hlapp at gmx.net, 2002.
14 # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
16 # You may distribute this module under the same terms as perl itself.
17 # Refer to the Perl Artistic License (see the license accompanying this
18 # software package, or see http://www.perl.com/language/misc/Artistic.html)
19 # for the terms under which you may use, modify, and redistribute this module.
21 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
22 # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
23 # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26 # POD documentation - main docs before the code
30 Bio::Cluster::ClusterFactory - Instantiates a new Bio::ClusterI (or derived class) through a factory
34 use Bio::Cluster::ClusterFactory;
35 # if you don't provide a default type, the factory will try
36 # some guesswork based on display_id and namespace
37 my $factory = Bio::Cluster::ClusterFactory->new(-type => 'Bio::Cluster::UniGene');
38 my $clu = $factory->create_object(-description => 'NAT',
39 -display_id => 'Hs.2');
44 This object will build L<Bio::ClusterI> objects generically.
50 User feedback is an integral part of the evolution of this and other
51 Bioperl modules. Send your comments and suggestions preferably to
52 the Bioperl mailing list. Your participation is much appreciated.
54 bioperl-l@bioperl.org - General discussion
55 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
59 Please direct usage questions or support issues to the mailing list:
61 I<bioperl-l@bioperl.org>
63 rather than to the module maintainer directly. Many experienced and
64 reponsive experts will be able look at the problem and quickly
65 address it. Please include a thorough description of the problem
66 with code and data examples if at all possible.
70 Report bugs to the Bioperl bug tracking system to help us keep track
71 of the bugs and their resolution. Bug reports can be submitted via the
74 https://redmine.open-bio.org/projects/bioperl/
76 =head1 AUTHOR - Hilmar Lapp
78 Email hlapp at gmx.net
83 The rest of the documentation details each of the object methods.
84 Internal methods are usually preceded with a _
89 # Let the code begin...
92 package Bio
::Cluster
::ClusterFactory
;
97 use base
qw(Bio::Factory::ObjectFactory);
102 Usage : my $obj = Bio::Cluster::ClusterFactory->new();
103 Function: Builds a new Bio::Cluster::ClusterFactory object
104 Returns : Bio::Cluster::ClusterFactory
105 Args : -type => string, name of a ClusterI derived class.
106 If not provided, the factory will have to guess
107 from ID and namespace, which may or may not be
113 my($class,@args) = @_;
115 my $self = $class->SUPER::new
(@args);
117 $self->interface("Bio::ClusterI");
118 $self->type($self->type) if $self->type;
126 Title : create_object
127 Usage : my $seq = $factory->create_object(<named parameters>);
128 Function: Instantiates new Bio::ClusterI (or one of its child classes)
130 This object allows us to genericize the instantiation of
133 Returns : L<Bio::ClusterI> compliant object
134 The return type is configurable using new(-type =>"...").
135 Args : initialization parameters specific to the type of cluster
136 object we want. Typically
138 -description => description of the cluster
139 -members => arrayref, members of the cluster
144 my ($self,@args) = @_;
146 my $type = $self->type();
148 # we need to guess this
149 $type = $self->_guess_type(@args);
150 $self->throw("No cluster type set and unable to guess.") unless $type;
153 return $type->new(-verbose
=> $self->verbose, @args);
160 Function: Guesses the right type of L<Bio::ClusterI> implementation
161 based on initialization parameters for the prospective
164 Returns : the type (a string, the module name)
165 Args : initialization parameters to be passed to the prospective
172 my ($self,@args) = @_;
175 # we can only guess from a certain number of arguments
176 my ($dispid, $ns, $members) =
177 $self->_rearrange([qw(DISPLAY_ID
181 # Unigene namespace or ID?
182 if($ns && (lc($ns) eq "unigene")) {
183 $type = 'Bio::Cluster::UniGene';
184 } elsif($dispid && ($dispid =~ /^Hs\.[0-9]/)) {
185 $type = 'Bio::Cluster::UniGene';
187 # what else could we look for?