File: Matrix.pm

package info (click to toggle)
libtfbs-perl 0.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,608 kB
  • ctags: 725
  • sloc: perl: 6,980; ansic: 699; makefile: 557; sh: 9
file content (50 lines) | stat: -rwxr-xr-x 1,208 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package TFBS::PatternGen::Motif::Matrix;
use vars qw(@ISA);
use strict;
 
use TFBS::Matrix;
use TFBS::Matrix::PFM;

@ISA = qw(TFBS::Matrix);

sub new  {
    my ($caller, %args) = @_;
    #my $matrix = TFBS::Matrix->new(%args, -matrixtype=>"PFM");
    #my $self = bless $matrix, ref($caller) || $caller;
    my $self = $caller->SUPER::new(%args, -matrixtype=>"PFM");
    $self->{'length'} = $args{'-length'} || scalar @{$self->{'matrix'}->[0]};
    $self->{'nr_hits'} = ($args{'-nr_hits'} || undef);
    #           || $self->throw("No -nr_hits provided.");
    # Why was nr_hits required ?? (Boris)
    $self->{'sites'}=$args{'-sites'};
    # $self->{'tags'} = ($args{'-tags'} || {});
    return $self;
}

sub PFM  {
    my ($self, %args) = @_;
    return TFBS::Matrix::PFM->new (-name => "unknown",
				   -ID   => "unknown",
				   -class=> "unknown",
				   -tags => { %{$self->{'tags'} } },
				   %args,
				   -matrix => $self->_calculate_PFM()
				   );
}

sub pattern {
    my ($self, %args ) = @_;
    $self->PFM(%args);
}


sub _calculate_PFM  { # simplest case: matrix already IS PFM
    my $self = shift;
    return [@{$self->{'matrix'}}];
}

sub get_sites{
    return @{$_[0]->{'sites'}};
}

1;