JPRED-2 Move Jpred 3.0.1 to public Git
[jpred.git] / jpred / lib / HMMER / Profile / Jnet.pm
1 package HMMER::Profile::Jnet;
2
3 use strict;
4 use warnings;
5 use Carp;
6
7 use base qw(HMMER::Profile Write);
8
9 sub read {
10         my ($self, $fh) = @_;
11
12         local $/ = "\n";
13
14         while (my $line = <$fh>) {
15                 chomp $line;
16                 my @data = split / /, $line;
17                 croak "HMMER::Profile::Jnet: Wrong number of data items in ".$self->path." at line $." if @data != 24;
18                 $self->add_line(@data);
19         }
20 }
21
22 sub jnet {
23         my ($self) = @_;
24         my @data;
25         for ($self->get_line) {
26                 # This provides the same output as for hmm2profile
27                 push @data, [
28                         map {
29                                 sprintf "%2.5f", 1 / (1 + (exp(-($_ / 100))));
30                         } @{$_}
31                 ];
32         }
33         @data;
34 }
35
36 sub write {
37         my ($self, $fh) = @_;
38
39         #die "Sorry, I don't think you mean to use this function. If you do, remove this line";
40
41         for ($self->jnet) {
42                 print $fh join(" ", @{$_}), "\n";
43         }
44 }
45
46 *seq = *jnet;
47
48 1;
49
50 __END__
51
52 =head1 NAME
53
54 HMMER::Profile::Jnet - Read in the data output from HMMER::Profile::jnet()
55
56 =head1 DESCRIPTION
57
58 Reads the output of the HMMER::Profile::jnet() function.
59
60 =head1 METHODS
61
62 =head2 my $prof = HMMER::Profile::Jnet->new;
63
64 Create a new object.
65
66 =head2 $prof->read_file($path_to_file);
67
68 Read in the data.
69
70 =head2 my @data = $prof->seq
71
72 Returns an AoA of the numbers.
73
74 =head1 SEE ALSO
75
76 Packages Root, Read, Sequence and HMMER::Profile.
77
78 =head1 AUTHOR
79
80 Jonathan Barber <jon@compbio.dundee.ac.uk>