| 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::Wordscip-perl cpan TFBS v0.5.0 TFBS/Word/; |
| 40 | use varsscip-perl cpan TFBS v0.5.0 vars/ '@ISA'; |
| 41 | |
| 42 | use TFBS::PatternIscip-perl cpan TFBS v0.5.0 TFBS/PatternI/; |
| 43 | |
| 44 | use strictscip-perl cpan TFBS v0.5.0 strict/; |
| 45 | |
| 46 | @ISAscip-perl cpan TFBS v0.5.0 TFBS/Word/`@ISA`. = qw(TFBS::PatternI); |
| 47 | |
| 48 | =head2 new |
| 49 | |
| 50 | =cut |
| 51 | |
| 52 | sub newscip-perl cpan TFBS v0.5.0 TFBS/Word/new(). { |
| 53 | my ($caller, @args) = @_scip-perl cpan TFBS v0.5.0 TFBS/Word/`@_`.; |
| 54 | my $self = $caller->SUPER::newscip-perl cpan TFBS v0.5.0 TFBS/Word/`SUPER::new`().(@args); |
| 55 | my ($id, $name, $class, $word, $tagref) = $self->_rearrangescip-perl cpan TFBS v0.5.0 TFBS/Word/_rearrange().([qw(ID NAME CLASS |
| 56 | WORD TAGS)], @args); |
| 57 | |
| 58 | if (definedscip-perl cpan TFBS v0.5.0 TFBS/Word/defined(). $word) { $self->wordscip-perl cpan TFBS v0.5.0 TFBS/Word/word().($word); } |
| 59 | else { $self->throwscip-perl cpan TFBS v0.5.0 TFBS/Word/throw().("Need a -word argument"); } |
| 60 | $self->namescip-perl cpan TFBS v0.5.0 TFBS/Word/name().($name); |
| 61 | $self->IDscip-perl cpan TFBS v0.5.0 TFBS/Word/ID().($id); |
| 62 | $self->{'tags'} = ($tagref or {}); |
| 63 | |
| 64 | return $self; |
| 65 | |
| 66 | } |
| 67 | |
| 68 | |
| 69 | =head2 word |
| 70 | |
| 71 | =cut |
| 72 | |
| 73 | sub wordscip-perl cpan TFBS v0.5.0 TFBS/Word/word(). { |
| 74 | my ($self, @args) = @_scip-perl cpan TFBS v0.5.0 TFBS/Word/`@_`.; |
| 75 | if(scalarscip-perl cpan TFBS v0.5.0 TFBS/Word/scalar().(@args) == 0) { |
| 76 | return $self->{'word'}; |
| 77 | } |
| 78 | my ($word) = @args; |
| 79 | |
| 80 | if (definedscip-perl cpan TFBS v0.5.0 TFBS/Word/defined(). $word and ! $self->validate_wordscip-perl cpan TFBS v0.5.0 TFBS/Word/validate_word().($word)) { |
| 81 | $self->throwscip-perl cpan TFBS v0.5.0 TFBS/Word/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_wordscip-perl cpan TFBS v0.5.0 TFBS/Word/validate_word(). { |
| 99 | shift->throwscip-perl cpan TFBS v0.5.0 shift/throw().("Error: method 'validate_word' not implemented"); |
| 100 | } |
| 101 | |
| 102 | =head2 length |
| 103 | |
| 104 | =cut |
| 105 | |
| 106 | sub lengthscip-perl cpan TFBS v0.5.0 TFBS/Word/length(). { |
| 107 | # wird length does not have to be defined, but its subroutine does |
| 108 | shift->throwscip-perl cpan TFBS v0.5.0 shift/throw().("Error: method 'length' not implemented"); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | |
| 113 | =head2 search_seq |
| 114 | |
| 115 | =cut |
| 116 | |
| 117 | sub search_seqscip-perl cpan TFBS v0.5.0 TFBS/Word/search_seq(). { |
| 118 | shift->throwscip-perl cpan TFBS v0.5.0 shift/throw().("Error: method search_seq not implemented"); |
| 119 | |
| 120 | } |
| 121 | |
| 122 | |
| 123 | =head2 search_aln |
| 124 | |
| 125 | =cut |
| 126 | |
| 127 | sub search_alnscip-perl cpan TFBS v0.5.0 TFBS/Word/search_aln(). { |
| 128 | shift->throwscip-perl cpan TFBS v0.5.0 shift/throw().("Error: method search_aln not implemented"); |
| 129 | } |
| 130 | |
| 131 | |
| 132 | 1; |