| 1 | # TFBS module for TFBS::PatternGen::Gibbs::Motif |
| 2 | # |
| 3 | # Copyright Boris Lenhard and Wynand Alkema |
| 4 | # |
| 5 | # You may distribute this module under the same terms as perl itself |
| 6 | # |
| 7 | |
| 8 | # POD |
| 9 | |
| 10 | |
| 11 | # POD |
| 12 | |
| 13 | =head1 NAME |
| 14 | |
| 15 | TFBS::PatternGen::Gibbs::Motif - class for unprocessed motifs and associated |
| 16 | numerical scores created by the Gibbs program |
| 17 | |
| 18 | |
| 19 | =head1 SYNOPSIS |
| 20 | |
| 21 | =head1 DESCRIPTION |
| 22 | |
| 23 | TFBS::PatternGen::Gibbs::Motif is used to store and manipulate unprocessed |
| 24 | motifs and associated numerical scores created by the Gibbs program. You do not |
| 25 | normally want to create a TFBS::PatternGen::Gibbs::Motif yourself. They are created |
| 26 | by running TFBS::PatternGen::Gibbs |
| 27 | |
| 28 | =head1 FEEDBACK |
| 29 | |
| 30 | Please send bug reports and other comments to the author. |
| 31 | |
| 32 | =head1 AUTHOR - Boris Lenhard and Wynand Alkema |
| 33 | |
| 34 | Boris Lenhard E<lt>[email protected]<gt> |
| 35 | Wynand Alkema E<lt>[email protected]<gt> |
| 36 | |
| 37 | =head1 APPENDIX |
| 38 | |
| 39 | The rest of the documentation details each of the object |
| 40 | methods. Internal methods are preceded with an underscore. |
| 41 | |
| 42 | =cut |
| 43 | |
| 44 | |
| 45 | |
| 46 | # the code begins here: |
| 47 | |
| 48 | package TFBS::PatternGen::Gibbs::Motif; |
| 49 | use vars qw(@ISA); |
| 50 | use strict; |
| 51 | |
| 52 | use TFBS::Matrix::PFM; |
| 53 | use TFBS::PatternGen::Motif::Matrix; |
| 54 | @ISA = qw(TFBS::PatternGen::Motif::Matrix); |
| 55 | |
| 56 | |
| 57 | |
| 58 | =head2 MAP |
| 59 | |
| 60 | Title : MAP |
| 61 | Usage : my $map_score = $motif->MAP; |
| 62 | Function: returns MAP score for the detected motif |
| 63 | (This is a backward compatibility method. For consistency, |
| 64 | you should use $motif->tag('MAP_score') instead |
| 65 | Returns : float (a scalar) |
| 66 | Args : none |
| 67 | |
| 68 | =head2 Other methods |
| 69 | |
| 70 | TFBS::PatterGen::Motif::Gibbs inherits from TFBS::PatternGen::Motif, |
| 71 | which inherits from TFBS::Matrix. Please consult the documentation of those modules |
| 72 | for additional available methods. |
| 73 | |
| 74 | |
| 75 | =cut |
| 76 | |
| 77 | sub MAP{ |
| 78 | my ($self) = @_; |
| 79 | return $self->tag("MAP_score"); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | |
| 84 | sub _calculate_PFM { |
| 85 | my $self = shift; |
| 86 | unless ($self->{'nr_hits'}) { |
| 87 | $self->throw(ref($self). |
| 88 | " objects must be created with a (nonzero)". |
| 89 | " -nr_hits parameter in constructor" |
| 90 | ); |
| 91 | } |
| 92 | my @PFM; |
| 93 | foreach my $rowref ( @{$self->{'matrix'}} ) { |
| 94 | my @PFMrow; |
| 95 | foreach my $element (@$rowref) { |
| 96 | push @PFMrow, int($self->{'nr_hits'}*$element/100 + 0.5); |
| 97 | } |
| 98 | push @PFM, [@PFMrow]; |
| 99 | } |
| 100 | return \@PFM; |
| 101 | } |
| 102 |