PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Bio/Pipeline/Argument.pm

https://github.com/bioperl/bioperl-pipeline
Perl | 235 lines | 170 code | 58 blank | 7 comment | 15 complexity | 92ff7a7a4f40c491221f0f69cdac9a24 MD5 | raw file
Possible License(s): LGPL-2.0
  1. #
  2. # BioPerl module for Bio::Pipeline::Argument
  3. #
  4. # You may distribute this module under the same terms as perl itself
  5. #
  6. # POD documentation - main docs before the code
  7. #
  8. =head1 NAME
  9. Bio::Pipeline::Argument
  10. =head1 SYNOPSIS
  11. use Bio::Pipeline::Argument;
  12. my $arg = new Bio::Pipeline::Argument(-dbID => $argument_id,
  13. -rank => $rank,
  14. -value=> $value,
  15. -tag => $tag,
  16. -type => $type);
  17. =head1 DESCRIPTION
  18. An encapsulation of the arguments to be passed to each datahandler
  19. method using a tag value system.
  20. =head1 FEEDBACK
  21. =head2 Mailing Lists
  22. User feedback is an integral part of the evolution of this and other
  23. Bioperl modules. Send your comments and suggestions preferably to one
  24. of the Bioperl mailing lists. Your participation is much appreciated.
  25. bioperl-pipeline@bioperl.org - General discussion
  26. http://bioperl.org/wiki/Mailing_lists - About the mailing lists
  27. =head2 Support
  28. Please direct usage questions or support issues to the mailing list:
  29. L<bioperl-l@bioperl.org>
  30. rather than to the module maintainer directly. Many experienced and
  31. reponsive experts will be able look at the problem and quickly
  32. address it. Please include a thorough description of the problem
  33. with code and data examples if at all possible.
  34. =head2 Reporting Bugs
  35. Report bugs to the Bioperl bug tracking system to help us keep track
  36. the bugs and their resolution. Bug reports can be submitted via email
  37. or the web:
  38. bioperl-bugs@bio.perl.org
  39. http://bugzilla.open-bio.org/
  40. =head1 AUTHOR
  41. Email fugui@fugu-sg.org
  42. =head1 APPENDIX
  43. The rest of the documentation details each of the object
  44. methods. Internal metho ds are usually preceded with a _
  45. =cut
  46. package Bio::Pipeline::Argument;
  47. use vars qw(@ISA);
  48. use strict;
  49. use Bio::Root::Root;
  50. @ISA = qw(Bio::Root::Root);
  51. =head2 new
  52. Title : new
  53. Usage : my $io = Bio::Pipeline::Argument->new($dbid,$tag,$value,$rank,$dhid,$type)
  54. Function: this constructor should only be used in the Input object IO_adaptor or IO objects
  55. generates a new Bio::Pipeline::Argument. It may represent static arguments that
  56. are found in the argument table (tied to datahandlers) or dynamic ones found in the
  57. dynamic_argument table (tied to Inputs)
  58. Returns : L<Bio::Pipeline::Argument>
  59. Args : dbID: the dbID of the argument (optional)
  60. tag : the tag of the argument(optional)
  61. value: the value of the argument(required)
  62. type : the type of the argument(SCALAR(DEFAULT) or ARRAY)
  63. rank : the order of the argument in the method call,
  64. eg. fetch(1,"swissprot");
  65. Argument 1 would have rank 1,
  66. Argument swissprot would have rank 2.
  67. If tag-value is used e.g. fetch(-id=>1, -db=>"swissprot")
  68. rank is probably not needed.
  69. =cut
  70. sub new {
  71. my($class,@args) = @_;
  72. my $self = $class->SUPER::new(@args);
  73. my ($dbID,$tag,$value,$rank,$dhID,$type)=$self->_rearrange([qw(DBID
  74. TAG
  75. VALUE
  76. RANK
  77. DHID
  78. TYPE)],@args);
  79. defined $value || $self->throw("Argument needs a value tag.");
  80. $type = $type || 'SCALAR';
  81. $rank = $rank || 1;
  82. $dbID && $self->dbID($dbID);
  83. $self->value($value);
  84. $self->type($type);
  85. $self->rank($rank);
  86. $tag && $self->tag($tag);
  87. $dhID && $self->dhID($dhID);
  88. return $self;
  89. }
  90. =head1 Member variable access
  91. These methods let you get at and set the member variables
  92. =head2 dbID
  93. Title : dbID
  94. Function : returns dbID
  95. Example : $data_adaptor->dbID();
  96. Returns : dbid of the data adaptor
  97. Args :
  98. =cut
  99. sub dbID {
  100. my ($self,$dbID) = @_;
  101. if($dbID){
  102. $self->{'_dbID'} = $dbID;
  103. }
  104. return $self->{'_dbID'};
  105. }
  106. =head2 dhID
  107. Title : dhID
  108. Function : returns dhID
  109. Example : $data_adaptor->dhID();
  110. Returns : data handler for dynamic argument
  111. Args :
  112. =cut
  113. sub dhID {
  114. my ($self,$dhID) = @_;
  115. if($dhID){
  116. $self->{'_dhID'} = $dhID;
  117. }
  118. return $self->{'_dhID'};
  119. }
  120. =head2 value
  121. Title : value
  122. Function : returns value
  123. Example : $Argument->value();
  124. Returns : value of the Argument
  125. Args :
  126. =cut
  127. sub value{
  128. my ($self,$value) = @_;
  129. if($value){
  130. $self->{'_value'} = $value;
  131. }
  132. return $self->{'_value'};
  133. }
  134. =head2 tag
  135. Title : tag
  136. Function : returns tag
  137. Example : $arg->tag ();
  138. Returns : tag of the Argument
  139. Args :
  140. =cut
  141. sub tag {
  142. my ($self,$tag) = @_;
  143. if($tag){
  144. $self->{'_tag'} = $tag;
  145. }
  146. return $self->{'_tag'};
  147. }
  148. =head2 type
  149. Title : type
  150. Function : returns type
  151. Example : $arg->type ();
  152. Returns : type of the Argument ('SCALAR' or 'ARRAY')
  153. Args :
  154. =cut
  155. sub type{
  156. my ($self,$type) = @_;
  157. if($type){
  158. $self->throw("Invalid argument type") unless (($type =~/SCALAR/m) || ($type=~/ARRAY/m));
  159. $self->{'_type'} = $type;
  160. }
  161. return $self->{'_type'};
  162. }
  163. =head2 rank
  164. Title : rank
  165. Function : returns rank
  166. Example : $argument->rank();
  167. Returns : rank the Argument
  168. Args :
  169. =cut
  170. sub rank{
  171. my ($self,$rank) = @_;
  172. if($rank) {
  173. $self->{'_rank'} = $rank;
  174. }
  175. return $self->{'_rank'};
  176. }
  177. 1;