PageRenderTime 70ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Bio/Ontology/TermI.pm

https://github.com/gjuggler/bioperl-live
Perl | 387 lines | 236 code | 123 blank | 28 comment | 20 complexity | 3b08cd10532f7767b3591a3b63e8e7c3 MD5 | raw file
  1. #
  2. # BioPerl module for Bio::Ontology::Term
  3. #
  4. # Please direct questions and support issues to <bioperl-l@bioperl.org>
  5. #
  6. # Cared for by Christian M. Zmasek <czmasek-at-burnham.org> or <cmzmasek@yahoo.com>
  7. #
  8. # (c) Christian M. Zmasek, czmasek-at-burnham.org, 2002.
  9. # (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
  10. #
  11. # You may distribute this module under the same terms as perl itself.
  12. # Refer to the Perl Artistic License (see the license accompanying this
  13. # software package, or see http://www.perl.com/language/misc/Artistic.html)
  14. # for the terms under which you may use, modify, and redistribute this module.
  15. #
  16. # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
  17. # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  18. # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #
  20. # You may distribute this module under the same terms as perl itself
  21. # POD documentation - main docs before the code
  22. =head1 NAME
  23. Bio::Ontology::TermI - interface for ontology terms
  24. =head1 SYNOPSIS
  25. #get Bio::Ontology::TermI somehow.
  26. print $term->identifier(), "\n";
  27. print $term->name(), "\n";
  28. print $term->definition(), "\n";
  29. print $term->is_obsolete(), "\n";
  30. print $term->comment(), "\n";
  31. foreach my $synonym ( $term->get_synonyms() ) {
  32. print $synonym, "\n";
  33. }
  34. =head1 DESCRIPTION
  35. This is "dumb" interface for ontology terms providing basic methods
  36. (it provides no functionality related to graphs).
  37. =head1 FEEDBACK
  38. =head2 Mailing Lists
  39. User feedback is an integral part of the evolution of this and other
  40. Bioperl modules. Send your comments and suggestions preferably to one
  41. of the Bioperl mailing lists. Your participation is much appreciated.
  42. bioperl-l@bioperl.org - General discussion
  43. http://bioperl.org/wiki/Mailing_lists - About the mailing lists
  44. =head2 Support
  45. Please direct usage questions or support issues to the mailing list:
  46. I<bioperl-l@bioperl.org>
  47. rather than to the module maintainer directly. Many experienced and
  48. reponsive experts will be able look at the problem and quickly
  49. address it. Please include a thorough description of the problem
  50. with code and data examples if at all possible.
  51. =head2 Reporting Bugs
  52. Report bugs to the Bioperl bug tracking system to help us keep track
  53. the bugs and their resolution. Bug reports can be submitted via
  54. the web:
  55. http://bugzilla.open-bio.org/
  56. =head1 AUTHOR
  57. Christian M. Zmasek
  58. Email: czmasek-at-burnham.org or cmzmasek@yahoo.com
  59. WWW: http://monochrome-effect.net/
  60. Address:
  61. Genomics Institute of the Novartis Research Foundation
  62. 10675 John Jay Hopkins Drive
  63. San Diego, CA 92121
  64. =head1 APPENDIX
  65. The rest of the documentation details each of the object
  66. methods.
  67. =cut
  68. # Let the code begin...
  69. package Bio::Ontology::TermI;
  70. use strict;
  71. use base qw(Bio::Root::RootI);
  72. =head2 identifier
  73. Title : identifier
  74. Usage : $term->identifier( "0003947" );
  75. or
  76. print $term->identifier();
  77. Function: Set/get for the identifier of this Term.
  78. Returns : The identifier [scalar].
  79. Args : The identifier [scalar] (optional).
  80. =cut
  81. sub identifier {
  82. shift->throw_not_implemented();
  83. } # identifier
  84. =head2 name
  85. Title : name
  86. Usage : $term->name( "N-acetylgalactosaminyltransferase" );
  87. or
  88. print $term->name();
  89. Function: Set/get for the name of this Term.
  90. Returns : The name [scalar].
  91. Args : The name [scalar] (optional).
  92. =cut
  93. sub name {
  94. shift->throw_not_implemented();
  95. } # name
  96. =head2 definition
  97. Title : definition
  98. Usage : $term->definition( "Catalysis of ..." );
  99. or
  100. print $term->definition();
  101. Function: Set/get for the definition of this Term.
  102. Returns : The definition [scalar].
  103. Args : The definition [scalar] (optional).
  104. =cut
  105. sub definition {
  106. shift->throw_not_implemented();
  107. } # definition
  108. =head2 ontology
  109. Title : ontology
  110. Usage : $ont = $term->ontology();
  111. or
  112. $term->ontology( $ont );
  113. Function: Get the ontology this term is in.
  114. An implementation may not permit the value of this
  115. attribute to be changed once it is set, since that may have
  116. serious consequences (note that with the ontology in hand
  117. you can query for all related terms etc).
  118. Note for implementors: you will almost certainly have to
  119. take special precaution in order not to create cyclical
  120. references in memory.
  121. Returns : The ontology of this Term as a Bio::Ontology::OntologyI
  122. implementing object.
  123. Args : On set, the ontology of this Term as a Bio::Ontology::OntologyI
  124. implementing object or a string representing its name.
  125. See L<Bio::Ontology::OntologyI>.
  126. =cut
  127. sub ontology {
  128. shift->throw_not_implemented();
  129. } # ontology
  130. =head2 version
  131. Title : version
  132. Usage : $term->version( "1.00" );
  133. or
  134. print $term->version();
  135. Function: Set/get for version information.
  136. Returns : The version [scalar].
  137. Args : The version [scalar] (optional).
  138. =cut
  139. sub version {
  140. shift->throw_not_implemented();
  141. } # version
  142. =head2 is_obsolete
  143. Title : is_obsolete
  144. Usage : $term->is_obsolete( 1 );
  145. or
  146. if ( $term->is_obsolete() )
  147. Function: Set/get for the obsoleteness of this Term.
  148. Returns : the obsoleteness [0 or 1].
  149. Args : the obsoleteness [0 or 1] (optional).
  150. =cut
  151. sub is_obsolete {
  152. shift->throw_not_implemented();
  153. } # is_obsolete
  154. =head2 comment
  155. Title : comment
  156. Usage : $term->comment( "Consider the term ..." );
  157. or
  158. print $term->comment();
  159. Function: Set/get for an arbitrary comment about this Term.
  160. Returns : A comment.
  161. Args : A comment (optional).
  162. =cut
  163. sub comment {
  164. shift->throw_not_implemented();
  165. } # comment
  166. =head2 get_synonyms
  167. Title : get_synonyms
  168. Usage : @aliases = $term->get_synonyms();
  169. Function: Returns a list of aliases of this Term.
  170. If an implementor of this interface permits modification of
  171. this array property, the class should define at least
  172. methods add_synonym() and remove_synonyms(), with obvious
  173. functionality.
  174. Returns : A list of aliases [array of [scalar]].
  175. Args :
  176. =cut
  177. sub get_synonyms {
  178. shift->throw_not_implemented();
  179. } # get_synonyms
  180. =head2 get_dblinks
  181. Title : get_dblinks()
  182. Usage : @ds = $term->get_dblinks();
  183. Function: Returns a list of each dblink of this term.
  184. If an implementor of this interface permits modification of
  185. this array property, the class should define at least
  186. methods add_dblink() and remove_dblinks(), with obvious
  187. functionality.
  188. Returns : A list of dblinks [array of [scalars]].
  189. Args :
  190. Note : This has been deprecated in favor of get_dbxrefs()
  191. =cut
  192. sub get_dblinks {
  193. shift->throw('get_dblinks() is deprecated, use get_dbxrefs() instead');
  194. } # get_dblinks
  195. =head2 get_dbxrefs
  196. Title : get_dbxrefs()
  197. Usage : @ds = $term->get_dbxrefs();
  198. Function: Returns a list of each link for this term.
  199. If an implementor of this interface permits modification of
  200. this array property, the class should define at least
  201. methods add_dbxref() and remove_dbxrefs(), with obvious
  202. functionality.
  203. Returns : A list of dblinks. This can return a mixed 'bag' of scalars and
  204. L<Bio::Annotation::DBLink> instances, or specific subgroups
  205. can be returned based on passed arguments
  206. Args : implementation-specific
  207. =cut
  208. sub get_dbxrefs {
  209. shift->throw_not_implemented();
  210. } # get_dblinks
  211. =head2 get_secondary_ids
  212. Title : get_secondary_ids
  213. Usage : @ids = $term->get_secondary_ids();
  214. Function: Returns a list of secondary identifiers of this Term.
  215. Secondary identifiers mostly originate from merging terms,
  216. or possibly also from splitting terms.
  217. If an implementor of this interface permits modification of
  218. this array property, the class should define at least
  219. methods add_secondary_id() and remove_secondary_ids(), with
  220. obvious functionality.
  221. Returns : A list of secondary identifiers [array of [scalar]]
  222. Args :
  223. =cut
  224. sub get_secondary_ids {
  225. shift->throw_not_implemented();
  226. } # get_secondary_ids
  227. =head1 Deprecated methods
  228. Used for looking up the methods that supercedes them.
  229. =cut
  230. =head2 category
  231. Title : category
  232. Usage :
  233. Function: This method is deprecated. Use ontology() instead. We provide
  234. an implementation here that preserves backwards compatibility,
  235. but if you do not have legacy code using it you should not be
  236. calling this method.
  237. Example :
  238. Returns :
  239. Args :
  240. =cut
  241. sub category {
  242. my $self = shift;
  243. $self->warn("TermI::category is deprecated and being phased out. ".
  244. "Use TermI::ontology instead.");
  245. # called in set mode?
  246. if(@_) {
  247. # yes; what is incompatible with ontology() is if we were given
  248. # a TermI object
  249. my $arg = shift;
  250. $arg = $arg->name() if ref($arg) && $arg->isa("Bio::Ontology::TermI");
  251. return $self->ontology($arg,@_);
  252. } else {
  253. # No, called in get mode. This is always incompatible with ontology()
  254. # since category is supposed to return a TermI.
  255. my $ont = $self->ontology();
  256. my $term;
  257. if(defined($ont)) {
  258. $term = Bio::Ontology::Term->new(-name => $ont->name(),
  259. -identifier =>$ont->identifier());
  260. }
  261. return $term;
  262. }
  263. } # category
  264. 1;