/usr/share/perl5/Bio/Annotation/Comment.pm is in libbio-perl-perl 1.6.924-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | #
# BioPerl module for Bio::Annotation::Comment
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Ewan Birney <birney@ebi.ac.uk>
#
# Copyright Ewan Birney
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::Annotation::Comment - A comment object, holding text
=head1 SYNOPSIS
$comment = Bio::Annotation::Comment->new();
$comment->text("This is the text of this comment");
$annotation->add_Annotation('comment', $comment);
=head1 DESCRIPTION
A holder for comments in annotations, just plain text. This is a very simple
object, and justifiably so.
=head1 AUTHOR - Ewan Birney
Email birney@ebi.ac.uk
=head1 APPENDIX
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
=cut
# Let the code begin...
package Bio::Annotation::Comment;
use strict;
use base qw(Bio::Root::Root Bio::AnnotationI);
=head2 new
Title : new
Usage : $comment = Bio::Annotation::Comment->new( '-text' => 'some text for this comment');
Function: This returns a new comment object, optionally with
text filed
Example :
Returns : a Bio::Annotation::Comment object
Args : a hash with -text optionally set
=cut
sub new {
my($class,@args) = @_;
my $self = $class->SUPER::new(@args);
my ($text,$tag, $type) = $self->_rearrange([qw(TEXT TAGNAME TYPE)], @args);
defined $text && $self->text($text);
defined $tag && $self->tagname($tag);
defined $type && $self->type($type);
return $self;
}
=head1 AnnotationI implementing functions
=cut
=head2 as_text
Title : as_text
Usage :
Function:
Example :
Returns :
Args :
=cut
sub as_text{
my ($self) = @_;
return "Comment: ".$self->text;
}
=head2 display_text
Title : display_text
Usage : my $str = $ann->display_text();
Function: returns a string. Unlike as_text(), this method returns a string
formatted as would be expected for te specific implementation.
One can pass a callback as an argument which allows custom text
generation; the callback is passed the current instance and any text
returned
Example :
Returns : a string
Args : [optional] callback
=cut
{
my $DEFAULT_CB = sub {$_[0]->text || ''};
sub display_text {
my ($self, $cb) = @_;
$cb ||= $DEFAULT_CB;
$self->throw("Callback must be a code reference") if ref $cb ne 'CODE';
return $cb->($self);
}
}
=head2 hash_tree
Title : hash_tree
Usage :
Function:
Example :
Returns :
Args :
=cut
sub hash_tree{
my $self = shift;
my $h = {};
$h->{'text'} = $self->text;
return $h;
}
=head2 tagname
Title : tagname
Usage : $obj->tagname($newval)
Function: Get/set the tagname for this annotation value.
Setting this is optional. If set, it obviates the need to
provide a tag to Bio::AnnotationCollectionI when adding
this object. When obtaining an AnnotationI object from the
collection, the collection will set the value to the tag
under which it was stored unless the object has a tag
stored already.
Example :
Returns : value of tagname (a scalar)
Args : new value (a scalar, optional)
=cut
sub tagname{
my ($self,$value) = @_;
if( defined $value) {
$self->{'tagname'} = $value;
}
return $self->{'tagname'};
}
=head1 Specific accessors for Comments
=cut
=head2 text
Title : text
Usage : $value = $self->text($newval)
Function: get/set for the text field. A comment object
just holds a single string which is accessible through
this method
Example :
Returns : value of text
Args : newvalue (optional)
=cut
sub text{
my ($self,$value) = @_;
if( defined $value) {
$self->{'text'} = $value;
}
return $self->{'text'};
}
=head2 value
Title : value
Usage : $value = $self->value($newval)
Function: Alias of the 'text' method
Example :
Returns : value of text
Args : newvalue (optional)
=cut
*value = \&text;
=head2 type
Title : type
Usage : $value = $self->type($newval)
Function: get/set for the comment type field. The comment type
is normally found as a subfield within comment sections
in some files, such as SwissProt
Example :
Returns : value of text
Args : newvalue (optional)
=cut
sub type {
my ($self,$type) = @_;
if( defined $type) {
$self->{'type'} = $type;
}
return $self->{'type'};
}
1;
|