34
34
use Bio::Annotation::AnnotationFactory;
36
my $factory = new Bio::Annotation::AnnotationFactory(
36
my $factory = Bio::Annotation::AnnotationFactory->new(
37
37
-type => 'Bio::Annotation::SimpleValue');
38
38
my $ann = $factory->create_object(-value => 'peroxisome',
39
39
-tagname => 'cellular component');
96
Usage : my $obj = new Bio::Annotation::AnnotationFactory();
96
Usage : my $obj = Bio::Annotation::AnnotationFactory->new();
97
97
Function: Builds a new Bio::Annotation::AnnotationFactory object
98
98
Returns : Bio::Annotation::AnnotationFactory
99
99
Args : -type => string, name of a L<Bio::AnnotationI> derived class.
141
141
# we need to guess this
142
142
$type = $self->_guess_type(@args);
144
$self->throw("No annotation type set and unable to guess.");
144
$self->throw("No annotation type set and unable to guess.");
146
146
# load dynamically if it hasn't been loaded yet
147
147
if(! $self->{'_loaded_types'}->{$type}) {
149
$self->_load_module($type);
150
$self->{'_loaded_types'}->{$type} = 1;
153
$self->throw("Bio::AnnotationI implementation $type ".
154
"failed to load: ".$@);
149
$self->_load_module($type);
150
$self->{'_loaded_types'}->{$type} = 1;
153
$self->throw("Bio::AnnotationI implementation $type ".
154
"failed to load: ".$@);
158
158
return $type->new(-verbose => $self->verbose, @args);
177
177
my $self = shift;
181
if($type && (! $self->{'_loaded_types'}->{$type})) {
183
$self->_load_module($type);
186
$self->throw("Annotation class '$type' failed to load: ".
189
my $a = bless {},$type;
190
if( ! $a->isa('Bio::AnnotationI') ) {
191
$self->throw("'$type' does not implement Bio::AnnotationI. ".
194
$self->{'_loaded_types'}->{$type} = 1;
196
return $self->{'type'} = $type;
181
if($type && (! $self->{'_loaded_types'}->{$type})) {
183
$self->_load_module($type);
186
$self->throw("Annotation class '$type' failed to load: ".
189
my $a = bless {},$type;
190
if( ! $a->isa('Bio::AnnotationI') ) {
191
$self->throw("'$type' does not implement Bio::AnnotationI. ".
194
$self->{'_loaded_types'}->{$type} = 1;
196
return $self->{'type'} = $type;
198
198
return $self->{'type'};
220
220
# we can only guess from a certain number of arguments
221
my ($val,$db,$text,$name,$authors, $start) =
222
$self->_rearrange([qw(VALUE
230
$val && do { $type = "SimpleValue"; last SWITCH; };
231
$authors && do { $type = "Reference"; last SWITCH; };
232
$db && do { $type = "DBLink"; last SWITCH; };
233
$text && do { $type = "Comment"; last SWITCH; };
234
$name && do { $type = "OntologyTerm"; last SWITCH; };
235
$start && do { $type = "Target"; last SWITCH; };
236
# what else could we look for?
221
my ($val, $db, $text, $name, $authors, $start, $tree, $node) =
222
$self->_rearrange([qw(VALUE
232
$val && do { $type = ref($val) ? "TagTree" : "SimpleValue"; last SWITCH; };
233
$authors && do { $type = "Reference"; last SWITCH; };
234
$db && do { $type = "DBLink"; last SWITCH; };
235
$text && do { $type = "Comment"; last SWITCH; };
236
$name && do { $type = "OntologyTerm"; last SWITCH; };
237
$start && do { $type = "Target"; last SWITCH; };
238
$tree && do { $type = "Tree"; last SWITCH; };
239
$node && do { $type = "TagTree"; last SWITCH; };
240
# what else could we look for?
238
242
$type = "Bio::Annotation::".$type;