1
# $Id: ClusterFactory.pm,v 1.3 2003/03/27 08:54:24 lapp Exp $
3
# BioPerl module for Bio::Cluster::ClusterFactory
5
# Cared for by Hilmar Lapp <hlapp at gmx.net>
7
# Copyright Hilmar Lapp
9
# You may distribute this module under the same terms as perl itself
12
# (c) Hilmar Lapp, hlapp at gmx.net, 2002.
13
# (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
15
# You may distribute this module under the same terms as perl itself.
16
# Refer to the Perl Artistic License (see the license accompanying this
17
# software package, or see http://www.perl.com/language/misc/Artistic.html)
18
# for the terms under which you may use, modify, and redistribute this module.
20
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
21
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
22
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25
# POD documentation - main docs before the code
29
Bio::Cluster::ClusterFactory - Instantiates a new Bio::ClusterI (or derived class) through a factory
33
use Bio::Cluster::ClusterFactory;
34
# if you don't provide a default type, the factory will try
35
# some guesswork based on display_id and namespace
36
my $factory = new Bio::Cluster::ClusterFactory(-type => 'Bio::Cluster::UniGene');
37
my $clu = $factory->create_object(-description => 'NAT',
38
-display_id => 'Hs.2');
43
This object will build L<Bio::ClusterI> objects generically.
49
User feedback is an integral part of the evolution of this and other
50
Bioperl modules. Send your comments and suggestions preferably to
51
the Bioperl mailing list. Your participation is much appreciated.
53
bioperl-l@bioperl.org - General discussion
54
http://bioperl.org/MailList.shtml - About the mailing lists
58
Report bugs to the Bioperl bug tracking system to help us keep track
59
of the bugs and their resolution. Bug reports can be submitted via
62
bioperl-bugs@bioperl.org
63
http://bugzilla.bioperl.org/
65
=head1 AUTHOR - Hilmar Lapp
67
Email hlapp at gmx.net
72
The rest of the documentation details each of the object methods.
73
Internal methods are usually preceded with a _
78
# Let the code begin...
81
package Bio::Cluster::ClusterFactory;
86
use Bio::Factory::ObjectFactory;
88
@ISA = qw(Bio::Factory::ObjectFactory);
93
Usage : my $obj = new Bio::Cluster::ClusterFactory();
94
Function: Builds a new Bio::Cluster::ClusterFactory object
95
Returns : Bio::Cluster::ClusterFactory
96
Args : -type => string, name of a ClusterI derived class.
97
If not provided, the factory will have to guess
98
from ID and namespace, which may or may not be
104
my($class,@args) = @_;
106
my $self = $class->SUPER::new(@args);
108
$self->interface("Bio::ClusterI");
109
$self->type($self->type) if $self->type;
117
Title : create_object
118
Usage : my $seq = $factory->create_object(<named parameters>);
119
Function: Instantiates new Bio::ClusterI (or one of its child classes)
121
This object allows us to genericize the instantiation of
124
Returns : L<Bio::ClusterI> compliant object
125
The return type is configurable using new(-type =>"...").
126
Args : initialization parameters specific to the type of cluster
127
object we want. Typically
129
-description => description of the cluster
130
-members => arrayref, members of the cluster
135
my ($self,@args) = @_;
137
my $type = $self->type();
139
# we need to guess this
140
$type = $self->_guess_type(@args);
141
$self->throw("No cluster type set and unable to guess.") unless $type;
144
return $type->new(-verbose => $self->verbose, @args);
151
Function: Guesses the right type of L<Bio::ClusterI> implementation
152
based on initialization parameters for the prospective
155
Returns : the type (a string, the module name)
156
Args : initialization parameters to be passed to the prospective
163
my ($self,@args) = @_;
166
# we can only guess from a certain number of arguments
167
my ($dispid, $ns, $members) =
168
$self->_rearrange([qw(DISPLAY_ID
172
# Unigene namespace or ID?
173
if($ns && (lc($ns) eq "unigene")) {
174
$type = 'Bio::Cluster::UniGene';
175
} elsif($dispid && ($dispid =~ /^Hs\.[0-9]/)) {
176
$type = 'Bio::Cluster::UniGene';
178
# what else could we look for?