| 1 | # TFBS module for TFBS::Word |
| 2 | # |
| 3 | # Copyright Boris Lenhard |
| 4 | # |
| 5 | # You may distribute this module under the same terms as perl itself |
| 6 | # |
| 7 | |
| 8 | # POD |
| 9 | |
| 10 | =head1 NAME |
| 11 | |
| 12 | TFBS::Word - base class for word-based patterns |
| 13 | |
| 14 | =head1 DESCRIPTION |
| 15 | |
| 16 | TFBS::Word is a base class consisting of universal constructor called by |
| 17 | its subclasses (TFBS::Matrix::*), and word pattern manipulation methods that |
| 18 | are independent of the word type. It is not meant to be instantiated itself. |
| 19 | |
| 20 | =head1 FEEDBACK |
| 21 | |
| 22 | Please send bug reports and other comments to the author. |
| 23 | |
| 24 | =head1 AUTHOR - Boris Lenhard |
| 25 | |
| 26 | Boris Lenhard E<lt>[email protected]<gt> |
| 27 | |
| 28 | =head1 APPENDIX |
| 29 | |
| 30 | The rest of the documentation details each of the object |
| 31 | methods. Internal methods are preceded with an underscore. |
| 32 | |
| 33 | =cut |
| 34 | |
| 35 | |
| 36 | |
| 37 | # The code begins HERE: |
| 38 | |
| 39 | package TFBS::Word; |
| 40 | use vars '@ISA'; |
| 41 | |
| 42 | use TFBS::PatternI; |
| 43 | |
| 44 | use strict; |
| 45 | |
| 46 | @ISA = qw(TFBS::PatternI); |
| 47 | |
| 48 | =head2 new |
| 49 | |
| 50 | =cut |
| 51 | |
| 52 | sub new { |
| 53 | my ($caller, @args) = @_; |
| 54 | my $self = $caller->SUPER::new(@args); |
| 55 | my ($id, $name, $class, $word, $tagref) = $self->_rearrange([qw(ID NAME CLASS |
| 56 | WORD TAGS)], @args); |
| 57 | |
| 58 | if (defined $word) { $self->word($word); } |
| 59 | else { $self->throw("Need a -word argument"); } |
| 60 | $self->name($name); |
| 61 | $self->ID($id); |
| 62 | $self->{'tags'} = ($tagref or {}); |
| 63 | |
| 64 | return $self; |
| 65 | |
| 66 | } |
| 67 | |
| 68 | |
| 69 | =head2 word |
| 70 | |
| 71 | =cut |
| 72 | |
| 73 | sub word { |
| 74 | my ($self, @args) = @_; |
| 75 | if(scalar(@args) == 0) { |
| 76 | return $self->{'word'}; |
| 77 | } |
| 78 | my ($word) = @args; |
| 79 | |
| 80 | if (defined $word and ! $self->validate_word($word)) { |
| 81 | $self->throw("Trying to set the word to an invalid value: $word"); |
| 82 | |
| 83 | } |
| 84 | else { |
| 85 | return $self->{'word'} = $word; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | |
| 90 | |
| 91 | =head2 validate_word |
| 92 | |
| 93 | Required in all subclasses |
| 94 | |
| 95 | =cut |
| 96 | |
| 97 | |
| 98 | sub validate_word { |
| 99 | shift->throw("Error: method 'validate_word' not implemented"); |
| 100 | } |
| 101 | |
| 102 | =head2 length |
| 103 | |
| 104 | =cut |
| 105 | |
| 106 | sub length { |
| 107 | # wird length does not have to be defined, but its subroutine does |
| 108 | shift->throw("Error: method 'length' not implemented"); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | |
| 113 | =head2 search_seq |
| 114 | |
| 115 | =cut |
| 116 | |
| 117 | sub search_seq { |
| 118 | shift->throw("Error: method search_seq not implemented"); |
| 119 | |
| 120 | } |
| 121 | |
| 122 | |
| 123 | =head2 search_aln |
| 124 | |
| 125 | =cut |
| 126 | |
| 127 | sub search_aln { |
| 128 | shift->throw("Error: method search_aln not implemented"); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | 1; |