2 # BioPerl module for Bio::Phenotype::MeSH::Twig
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
8 # You may distribute this module under the same terms as perl itself
10 # POD documentation - main docs before the code
14 Bio::Phenotype::MeSH::Twig - Context for a MeSH term
18 use Bio::Phenotype::MeSH::Twig
19 # create a twig object
20 my $twig = Bio::Phenotype::MeSH::Twig->new();
22 # the term has only one parent in any twig
23 $twig->parent('Fats');
26 # a twig makeas sense only in the context of a term
27 # which is a Bio::Phenotype::MeSH::Term object
29 # a term can have many twigs i.e. it can appear in many places in
32 $ term->add_twig($twig);
34 # adding the twig into a term adds a link into into it
37 # a twig can know about other terms under the parant node
38 $twig->add_sister('Bread', 'Candy', 'Cereals');
39 print join ( ', ', $twig->each_sister()), "\n";
41 # a twig can know about other terms under this term
42 $twig->add_child('Butter', 'Margarine');
43 print join ( ', ', $twig->each_child()), "\n";
49 This class represents the immediate surrounding of a MeSH term. It
50 keeps track on nodes names above the current node ('parent') other
51 nodes at the same level ('sisters') and nodes under it ('children').
52 Note that these are name strings, not objects.
54 Each twig can be associated with only one term, but term can have
55 multiple twigs. (Twigs can be though to be roles for a term.)
59 L<Bio::Phenotype::MeSH::Term>
65 User feedback is an integral part of the evolution of this and other
66 Bioperl modules. Send your comments and suggestions preferably to the
67 Bioperl mailing lists Your participation is much appreciated.
69 bioperl-l@bioperl.org - General discussion
70 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
74 Please direct usage questions or support issues to the mailing list:
76 I<bioperl-l@bioperl.org>
78 rather than to the module maintainer directly. Many experienced and
79 reponsive experts will be able look at the problem and quickly
80 address it. Please include a thorough description of the problem
81 with code and data examples if at all possible.
85 report bugs to the Bioperl bug tracking system to help us keep track
86 the bugs and their resolution. Bug reports can be submitted via the
89 https://github.com/bioperl/bioperl-live/issues
93 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
97 The rest of the documentation details each of the object
98 methods. Internal methods are usually preceded with a _
103 # Let the code begin...
105 package Bio
::Phenotype
::MeSH
::Twig
;
109 use base
qw(Bio::Root::Root);
114 my( $class,@args ) = @_;
115 my $self = $class->SUPER::new
( @args );
117 my ($term, $parent ) = $self->_rearrange
124 $self->{"_children"} = [];
125 $self->{"_sisters"} = [];
127 $term && $self->term($term );
128 $parent && $self->parent($parent );
136 Usage : $obj->parent( "r1" );
138 print $obj->parent();
139 Function: Set/get for the parent.
140 Returns : A parent [scalar].
141 Args : A parent [scalar] (optional).
146 my ( $self, $value ) = @_;
147 $self->{ "_parent" } = $value if defined $value;
148 return $self->{ "_parent" };
154 Usage : $obj->term( "r1" );
157 Function: Set/get for the term.
158 Returns : A term [scalar].
159 Args : A term [scalar] (optional).
164 my ( $self, $value ) = @_;
165 if (defined $value) {
166 $self->throw ("Not a MeSH term [$value]")
167 unless $value->isa('Bio::Phenotype::MeSH::Term');
168 $self->{ "_term" } = $value
170 return $self->{ "_term" };
177 Usage : $obj->add_child( @children );
179 $obj->add_child( $child );
180 Function: Pushes one or more child term names [scalars, most likely Strings]
181 into the list of children.
188 my ( $self, @values ) = @_;
189 push( @
{ $self->{ "_children" } }, @values );
190 return scalar @values;
196 Usage : @gs = $obj->each_child();
197 Function: Returns a list of gene symbols [scalars, most likely Strings]
198 associated with this phenotype.
199 Returns : A list of scalars.
205 my ( $self ) = shift;
206 return @
{ $self->{ "_children" } };
209 =head2 purge_children
211 Usage : $obj->purge_child();
212 Function: Deletes the list of children associated with this term.
213 Returns : A list of scalars.
220 $self->{ "_children" } = [];
227 Usage : $obj->add_sister( @sisters );
229 $obj->add_sister( $sister );
230 Function: Pushes one or more sister term names [scalars, most likely Strings]
231 into the list of sisters.
238 my ( $self, @values ) = @_;
239 push( @
{ $self->{ "_sisters" } }, @values );
240 return scalar @values;
245 Title : each_sister()
246 Usage : @gs = $obj->each_sister();
247 Function: Returns a list of gene symbols [scalars, most likely Strings]
248 associated with this phenotype.
249 Returns : A list of scalars.
255 my ( $self ) = shift;
256 return @
{ $self->{ "_sisters" } };
261 Usage : $obj->purge_sister();
262 Function: Deletes the list of sisters associated with this term.
263 Returns : A list of scalars.
270 $self->{'_sisters'} = [];