change rules for cluster accessible dirs.
[cxgn-corelibs.git] / lib / CXGN / Tools / Parse / SignalP.pm
blob96fc1e2383d87afb4728e3c33fd9adb438f2f205
1 package CXGN::Tools::Parse::SignalP;
2 use strict;
4 =head1 CXGN::Tools::Parse::SignalP
6 Parses output from SignalP V 3.0 in short format
8 =head1 Author
10 C. Carpita <csc32@cornell.edu>
12 =head1 Methods
14 =cut
16 =head2 new()
18 Args: (opt) raw output data
19 Ret: Parser object
20 Side: Calls parse() automatically if argument provided
22 =cut
24 sub new {
25 my $class = shift;
26 my $self = bless {}, $class;
27 my $data = shift;
28 if($data){
29 $self->{data} = $data;
30 $self->parse();
32 return $self;
35 sub parse_file {
36 my $self = shift;
37 my $filename = shift;
38 die "No file: $filename" unless (-f $filename);
39 open(FH, $filename);
40 $self->{data} .= $_ while <FH>;
41 close FH;
42 $self->parse();
45 sub parse {
46 my $self = shift;
47 my $data = $self->{data};
48 $self->{entries} = [];
49 $self->{entry_by_id} = {};
50 while(<$data>){
51 next if /^\s*#/;
52 my %h = ();
53 ($h{id}, $h{nn_cmax}, $h{nn_cpos}, $h{nn_cdec},
54 $h{nn_ymax}, $h{nn_ypos}, $h{nn_ydec},
55 $h{nn_smax}, $h{nn_spos}, $h{nn_sdec},
56 $h{nn_smean}, $h{nn_smeandec}, $h{nn_score}, $h{nn_decision},
57 $h{hmm_decision}, $h{hmm_cmax}, $h{hmm_cpos}, $h{hmm_cdec},
58 $h{hmm_sprob}, $h{hmm_sdec}
61 /^(\S+)\s+(\S+)\s+(\d+)\s+([NY])\s+(\S+)\s+(\d+)\s+([NY])\s+(\S+)\s+(\d+)\s+([NY])\s+(\S+)\s+([NY])\s+(\S+)\s+([NY])\s+\S+\s+([A-Z]+)\s+(\S+)\s+(\d+)\s+([NY])\s+(\S+)\s+([NY])/;
62 push(@{$self->{entries}}, \%h);
63 $self->{entry_by_id}->{$h{id}} = \%h;
67 sub getEntryById {
68 my $self = shift;
69 my $id = shift;
70 return $self->{entry_by_id}->{$id};
73 sub getEntryArray {
74 my $self = shift;
75 return @{$self->{entries}};