1 package PSIBLAST::PSSM;
7 use base qw(Root Read Write);
15 while (my $line = <$fh>) {
16 if ($line =~ /^\s{11}A R N D C Q E/) {
17 while ($line = <$fh>) {
19 last if $line =~ /^\s*$/;
21 my @pssm = split /\s+/, $line;
25 push @data, sprintf "%2.8f", 1 / (1 + (exp(- $_)));
29 $self->add_pos(@data);
37 my ($self, @data) = @_;
39 @data == 20 or croak "add_pos passed wrong length array";
41 push @{ $self->{__PACKAGE__."pos"} }, \@data;
50 if (defined (my $foo = $self->get_num_pos($i++))) {
61 my ($self, $data) = @_;
64 confess "Not passed ARRAY" unless ref $data eq 'ARRAY';
65 $self->add_pos(@{ $data });
68 my $size = $self->get_pos_size - 1;
70 return map { $self->get_num_pos($_) } 0..$size;
75 my ($self, $pos) = @_;
76 confess "No positions passed to get_num_pos" unless defined $pos;
77 return undef unless exists $self->{__PACKAGE__."pos"};
78 return ${ $self->{__PACKAGE__."pos"} }[$pos];
83 exists $self->{__PACKAGE__."pos"} ?
84 return scalar @{ $self->{__PACKAGE__."pos"} } :
90 while (my $pos = $self->get_pos) {
91 print $fh join(" ", @{$pos}), "\n"
101 PSIBLAST::PSSM - Read PSIBLAST PSSM files
105 my $pssm = PSIBLAST::PSSM->new;
106 $pssm->read_file("data.pssm");
109 print join(" ", @{$_}), "\n";
114 Class for reading PSIBLAST PSSM files, subclasses the Root, Read and Write classes.
118 =head2 my $pssm = PSIBLAST::PSSM->new()
120 Create the object. See Root module for details.
122 =head2 $pssm->read_file("path_to_file");
124 Read in a PSIBLAST PSSM file. See Read module for other methods.
126 =head2 $pssm->add_pos(@data);
128 Adds data from PSIBLAST PSSM.
130 =head2 $pssm->get_pos;
132 Itterator for returning the data for each position loaded in the object.
136 Prints the PSSM file for use by Jnet.
138 =head2 $pssm->seq([ @data ] );
145 Root, Read and Write modules.
149 Jonathan Barber <jon@compbio.dundee.ac.uk>