JPRED-2 Move Jpred 3.0.1 to public Git
[jpred.git] / jpred / lib / Profile / Scanps / Result.pm
1 package Profile::Scanps::Result;
2
3 use strict;
4 use warnings;
5 use Carp;
6 use base qw(Profile::Generic);
7 use Scanps::Result;
8
9 sub read {
10         my ($self, $fh) = @_;
11         my $scanps = Scanps::Result->new($fh);
12
13         # Get third, or last iteration, which ever is smaller
14         my $it = $scanps->iterations - 1;
15         $it > 2 and $it = 2; # iterations is zero based
16         my @positions = $scanps->profile($it);
17
18         for (@positions) {
19                 my (undef, @data) = split /\s+/, $_;
20                 $self->add_pos(@data[0..22]);
21         }
22 }
23
24 sub write {
25         my ($self, $fh) = @_;
26
27         while ((my @data = $self->get_pos) > 1) {
28                 print $fh map({ sprintf "%2.5f ", 1 / (1 + exp(-$_/100)) } @data), "\n";
29                 #print $fh join(" ", map  $_ / 100 } @data), "\n";
30                 #print $fh join(" ", @data), "\n";
31         }
32 }
33
34 1;
35
36 __END__
37
38 =head1 NAME
39
40 Profile::Scanps::Result - Reads a profile from a Scanps result file
41
42 =head1 DESCRIPTION
43
44 Reads the profile that can be provided at the end of a Scanps file.
45
46 =head1 INHERITANCE
47
48 Inherits from Profile and Generic modules.
49
50 =head1 METHODS
51
52 =head2 read()
53
54 =cut