Mercurial > repos > mahtabm > ensembl
comparison variant_effect_predictor/Bio/Annotation/Comment.pm @ 0:1f6dce3d34e0
Uploaded
| author | mahtabm |
|---|---|
| date | Thu, 11 Apr 2013 02:01:53 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:1f6dce3d34e0 |
|---|---|
| 1 # $Id: Comment.pm,v 1.8 2002/09/25 18:11:33 lapp Exp $ | |
| 2 # | |
| 3 # BioPerl module for Bio::Annotation::Comment | |
| 4 # | |
| 5 # Cared for by Ewan Birney <birney@ebi.ac.uk> | |
| 6 # | |
| 7 # Copyright Ewan Birney | |
| 8 # | |
| 9 # You may distribute this module under the same terms as perl itself | |
| 10 | |
| 11 # POD documentation - main docs before the code | |
| 12 | |
| 13 =head1 NAME | |
| 14 | |
| 15 Bio::Annotation::Comment - A comment object, holding text | |
| 16 | |
| 17 =head1 SYNOPSIS | |
| 18 | |
| 19 | |
| 20 $comment = Bio::Annotation::Comment->new(); | |
| 21 $comment->text("This is the text of this comment"); | |
| 22 $annotation->add_Annotation('comment', $comment); | |
| 23 | |
| 24 | |
| 25 =head1 DESCRIPTION | |
| 26 | |
| 27 A holder for comments in annotations, just plain text. This is a very simple | |
| 28 object, and justifiably so. | |
| 29 | |
| 30 =head1 CONTACT | |
| 31 | |
| 32 Describe contact details here | |
| 33 | |
| 34 =head1 APPENDIX | |
| 35 | |
| 36 The rest of the documentation details each of the object | |
| 37 methods. Internal methods are usually preceded with a _ | |
| 38 | |
| 39 =cut | |
| 40 | |
| 41 | |
| 42 # Let the code begin... | |
| 43 | |
| 44 package Bio::Annotation::Comment; | |
| 45 use vars qw(@ISA); | |
| 46 use strict; | |
| 47 | |
| 48 use Bio::Root::Root; | |
| 49 use Bio::AnnotationI; | |
| 50 | |
| 51 @ISA = qw(Bio::Root::Root Bio::AnnotationI); | |
| 52 | |
| 53 =head2 new | |
| 54 | |
| 55 Title : new | |
| 56 Usage : $comment = Bio::Annotation::Comment->new( '-text' => 'some text for this comment'); | |
| 57 Function: This returns a new comment object, optionally with | |
| 58 text filed | |
| 59 Example : | |
| 60 Returns : a Bio::Annotation::Comment object | |
| 61 Args : a hash with -text optionally set | |
| 62 | |
| 63 | |
| 64 =cut | |
| 65 | |
| 66 | |
| 67 sub new { | |
| 68 my($class,@args) = @_; | |
| 69 | |
| 70 my $self = $class->SUPER::new(@args); | |
| 71 my ($text,$tag) = $self->_rearrange([qw(TEXT TAGNAME)], @args); | |
| 72 | |
| 73 defined $text && $self->text($text); | |
| 74 defined $tag && $self->tagname($tag); | |
| 75 | |
| 76 return $self; | |
| 77 } | |
| 78 | |
| 79 =head1 AnnotationI implementing functions | |
| 80 | |
| 81 =cut | |
| 82 | |
| 83 =head2 as_text | |
| 84 | |
| 85 Title : as_text | |
| 86 Usage : | |
| 87 Function: | |
| 88 Example : | |
| 89 Returns : | |
| 90 Args : | |
| 91 | |
| 92 | |
| 93 =cut | |
| 94 | |
| 95 sub as_text{ | |
| 96 my ($self) = @_; | |
| 97 | |
| 98 return "Comment: ".$self->text; | |
| 99 } | |
| 100 | |
| 101 =head2 hash_tree | |
| 102 | |
| 103 Title : hash_tree | |
| 104 Usage : | |
| 105 Function: | |
| 106 Example : | |
| 107 Returns : | |
| 108 Args : | |
| 109 | |
| 110 | |
| 111 =cut | |
| 112 | |
| 113 sub hash_tree{ | |
| 114 my ($self) = @_; | |
| 115 | |
| 116 my $h = {}; | |
| 117 $h->{'text'} = $self->text; | |
| 118 } | |
| 119 | |
| 120 =head2 tagname | |
| 121 | |
| 122 Title : tagname | |
| 123 Usage : $obj->tagname($newval) | |
| 124 Function: Get/set the tagname for this annotation value. | |
| 125 | |
| 126 Setting this is optional. If set, it obviates the need to provide | |
| 127 a tag to Bio::AnnotationCollectionI when adding this object. When | |
| 128 obtaining an AnnotationI object from the collection, the collection | |
| 129 will set the value to the tag under which it was stored unless the | |
| 130 object has a tag stored already. | |
| 131 Example : | |
| 132 Returns : value of tagname (a scalar) | |
| 133 Args : new value (a scalar, optional) | |
| 134 | |
| 135 | |
| 136 =cut | |
| 137 | |
| 138 sub tagname{ | |
| 139 my ($self,$value) = @_; | |
| 140 if( defined $value) { | |
| 141 $self->{'tagname'} = $value; | |
| 142 } | |
| 143 return $self->{'tagname'}; | |
| 144 } | |
| 145 | |
| 146 =head1 Specific accessors for Comments | |
| 147 | |
| 148 =cut | |
| 149 | |
| 150 | |
| 151 =head2 text | |
| 152 | |
| 153 Title : text | |
| 154 Usage : $value = $self->text($newval) | |
| 155 Function: get/set for the text field. A comment object | |
| 156 just holds a single string which is accessible through | |
| 157 this method | |
| 158 Example : | |
| 159 Returns : value of text | |
| 160 Args : newvalue (optional) | |
| 161 | |
| 162 | |
| 163 =cut | |
| 164 | |
| 165 sub text{ | |
| 166 my ($self,$value) = @_; | |
| 167 if( defined $value) { | |
| 168 $self->{'text'} = $value; | |
| 169 } | |
| 170 return $self->{'text'}; | |
| 171 | |
| 172 } | |
| 173 | |
| 174 | |
| 175 | |
| 176 1; |
