JPRED-2 Move Jpred 3.0.1 to public Git
[jpred.git] / jpred / lib / SOV.pm
1 package SOV;
2
3 =head1 NAME
4
5 SOV - Parses output for CASP SOV program.
6
7 =head1 DESCRIPTION
8
9 Class for parsing SOV output.
10
11 =head1 METHODS
12
13 Inherits from Read and Root.
14
15 =cut
16
17 use base qw(Root Read);
18
19 =head2 q3()
20
21 Access q3 information. Returns SOV::Types object.
22
23 =head2 sov(), sov_0(), sov_50()
24
25 As for q3()
26
27 =cut
28
29 sub q3 {
30         if ($_[1]) { $_[0]->{q3} = $_[1] }
31         else { return defined $_[0]->{q3} ? $_[0]->{q3} : undef }
32 }
33
34 sub sov_0 {
35         if ($_[1]) { $_[0]->{sov_0} = $_[1] }
36         else { return defined $_[0]->{sov_0} ? $_[0]->{sov_0} : undef }
37 }
38
39 sub sov_50 {
40         if ($_[1]) { $_[0]->{sov_50} = $_[1] }
41         else { return defined $_[0]->{sov_50} ? $_[0]->{sov_50} : undef }
42 }
43
44 sub sov {
45         if ($_[1]) { $_[0]->{sov} = @_[1] }
46         else { return defined $_[0]->{sov} ? $_[0]->{sov} : undef }
47 }
48
49 sub read {
50         my ($self, $fh) = @_;
51
52         local $/ = "\n";
53         local $_;
54
55         # Get to the SOV and Q3 results
56         while (<$fh>) { last if /^\s-{22}/ }
57
58         while (<$fh>) {
59                 chomp;
60                 if (s/^\s*Q3\s*:\s*//) {
61                         $self->q3(to_struct(split / +/, $_))
62                 }
63                 elsif (s/^\s*SOV\s*:\s*//) {
64                         $self->sov(to_struct(split / +/, $_))
65                 }
66                 elsif (s/^\s*SOV.*0].*:\s*//) {
67                         $self->sov_0(to_struct(split / +/, $_))
68                 }
69                 elsif (s/^\s*SOV.*50%.*:\s*//) {
70                         $self->sov_50(to_struct(split / +/, $_))
71                 }
72         }
73
74 }
75
76 sub to_struct ($$$$) {
77         map { $_ > 1 ? $_ /= 100 : $_ } @_;
78         my $new = SOV::Types->new(
79                 all => +shift,
80                 helix => +shift,
81                 sheet => +shift,
82                 coil => +shift
83         );
84 }
85
86 =head1 SOV::Types
87
88 Object that stores prediction information
89
90 =head1 METHODS
91
92 =head2 all(), helix(), sheet(), coil()
93
94 Accessors for accuracy of different types of secondary structure.
95
96 =cut
97
98 use Class::Struct SOV::Types => [
99         all => '$', 
100         helix => '$',
101         sheet => '$',
102         coil => '$'
103 ];
104
105 =head1 AUTHOR
106
107 Jonathan Barber <jon@compbio.dundee.ac.uk>
108
109 =cut
110
111 1;