2 # BioPerl module for Bio::Annotation::Comment
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Ewan Birney <birney@ebi.ac.uk>
8 # Copyright Ewan Birney
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Annotation::Comment - A comment object, holding text
21 $comment = Bio::Annotation::Comment->new();
22 $comment->text("This is the text of this comment");
23 $annotation->add_Annotation('comment', $comment);
28 A holder for comments in annotations, just plain text. This is a very simple
29 object, and justifiably so.
31 =head1 AUTHOR - Ewan Birney
33 Email birney@ebi.ac.uk
37 The rest of the documentation details each of the object
38 methods. Internal methods are usually preceded with a _
43 # Let the code begin...
45 package Bio
::Annotation
::Comment
;
49 use base
qw(Bio::Root::Root Bio::AnnotationI);
54 Usage : $comment = Bio::Annotation::Comment->new( '-text' => 'some text for this comment');
55 Function: This returns a new comment object, optionally with
58 Returns : a Bio::Annotation::Comment object
59 Args : a hash with -text optionally set
66 my($class,@args) = @_;
68 my $self = $class->SUPER::new
(@args);
69 my ($text,$tag, $type) = $self->_rearrange([qw(TEXT TAGNAME TYPE)], @args);
71 defined $text && $self->text($text);
72 defined $tag && $self->tagname($tag);
73 defined $type && $self->type($type);
77 =head1 AnnotationI implementing functions
96 return "Comment: ".$self->text;
102 Usage : my $str = $ann->display_text();
103 Function: returns a string. Unlike as_text(), this method returns a string
104 formatted as would be expected for te specific implementation.
106 One can pass a callback as an argument which allows custom text
107 generation; the callback is passed the current instance and any text
111 Args : [optional] callback
116 my $DEFAULT_CB = sub {$_[0]->text || ''};
119 my ($self, $cb) = @_;
121 $self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
143 $h->{'text'} = $self->text;
150 Usage : $obj->tagname($newval)
151 Function: Get/set the tagname for this annotation value.
153 Setting this is optional. If set, it obviates the need to
154 provide a tag to Bio::AnnotationCollectionI when adding
155 this object. When obtaining an AnnotationI object from the
156 collection, the collection will set the value to the tag
157 under which it was stored unless the object has a tag
161 Returns : value of tagname (a scalar)
162 Args : new value (a scalar, optional)
168 my ($self,$value) = @_;
169 if( defined $value) {
170 $self->{'tagname'} = $value;
172 return $self->{'tagname'};
175 =head1 Specific accessors for Comments
183 Usage : $value = $self->text($newval)
184 Function: get/set for the text field. A comment object
185 just holds a single string which is accessible through
188 Returns : value of text
189 Args : newvalue (optional)
195 my ($self,$value) = @_;
196 if( defined $value) {
197 $self->{'text'} = $value;
199 return $self->{'text'};
206 Usage : $value = $self->value($newval)
207 Function: Alias of the 'text' method
209 Returns : value of text
210 Args : newvalue (optional)
221 Usage : $value = $self->type($newval)
222 Function: get/set for the comment type field. The comment type
223 is normally found as a subfield within comment sections
224 in some files, such as SwissProt
226 Returns : value of text
227 Args : newvalue (optional)
233 my ($self,$type) = @_;
235 $self->{'type'} = $type;
237 return $self->{'type'};