[Bio] / FigKernelPackages / Subsystem.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Subsystem.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.109, Thu Jun 14 19:46:50 2007 UTC revision 1.110, Wed Jul 18 18:08:43 2007 UTC
# Line 29  Line 29 
29    
30  use strict;  use strict;
31    
32    my $notes_separator = "###############################";
33    my @section_order = qw(description notes literature);
34    my %defined_sections = map { $_ => 1 } @section_order;
35    
36  =head1 Subsystem Manipulation  =head1 Subsystem Manipulation
37    
38  Any manipulation of subsystem data should happen through this interface.  Any manipulation of subsystem data should happen through this interface.
# Line 924  Line 928 
928  {  {
929      my($self) = @_;      my($self) = @_;
930    
931      $self->{notes} = &FIG::file_read(File::Spec->catfile($self->{dir}, "notes"));      #$self->{notes} = &FIG::file_read(File::Spec->catfile($self->{dir}, "notes"));
932    
933        my $nh = new FileHandle(File::Spec->catfile($self->{dir}, "notes"));
934    
935        $nh or return;
936    
937        my $section = "NOTES";
938        my $text;
939    
940        my $all;
941        $_ = <$nh>;
942        while (defined($_))
943        {
944            $all .= $_;
945            if (/^$notes_separator$/)
946            {
947                #
948                # Next line after the separator is the new section name, a single word. If the
949                # line doesn't match that, push it (and the current line) into the text and continue.
950                #
951                my $new_section = <$nh>;
952                if ($new_section =~ /^(\w+)\s*$/)
953                {
954                    $new_section = $1;
955                    $self->handle_note_section($section, $text) if defined($text);
956                    $section = $new_section;
957                    $text = '';
958                    $_ = <$nh>;
959                }
960                else
961                {
962                    $text .= $_;
963                    $_ = $section;
964                }
965            }
966            else
967            {
968                $text .= $_;
969                $_ = <$nh>;
970            }
971        }
972        $self->handle_note_section($section, $text);
973        $self->{raw_notes} = $all;
974    }
975    
976    sub handle_note_section
977    {
978        my($self, $section, $text) = @_;
979        print "Got section $section text=$text\n";
980    
981        my $sname = lc($section);
982        if (defined($defined_sections{$sname}))
983        {
984            $self->{$sname} = $text;
985        }
986        else
987        {
988            $self->{other_sections}->{$section} = $text;
989            warn "Loaded unknown section name $section\n";
990        }
991  }  }
992    
993  sub load_hope_kegg_info  sub load_hope_kegg_info
# Line 1456  Line 1519 
1519          chmod(0777,$ss_file);          chmod(0777,$ss_file);
1520    
1521          open($fh, ">$notes_file") or die "Cannot open $notes_file for writing: $!\n";          open($fh, ">$notes_file") or die "Cannot open $notes_file for writing: $!\n";
1522          print $fh "$self->{notes}";          for my $section (@section_order)
1523            {
1524                print $fh "$notes_separator\n";
1525                print $fh uc($section) . "\n";
1526                print $fh $self->{$section};
1527            }
1528            for my $osection (keys %{$self->{other_sections}})
1529            {
1530                print $fh "$notes_separator\n";
1531                print $fh uc($osection) . "\n";
1532                print $fh $self->{other_sections}->{$osection};
1533            }
1534            # print $fh "$self->{notes}";
1535    
1536          close($fh);          close($fh);
1537          chmod(0777,$notes_file);          chmod(0777,$notes_file);
1538    
# Line 3147  Line 3223 
3223      return $self->{notes};      return $self->{notes};
3224  }  }
3225    
3226    =head3 get_description
3227    
3228    C<< my $text = $sub->get_description(); >>
3229    
3230    Return the description for this subsystem.
3231    
3232    =cut
3233    
3234    sub get_description
3235    {
3236        my($self) = @_;
3237    
3238        return $self->{description};
3239    }
3240    
3241    =head3 get_literature
3242    
3243    C<< my $text = $sub->get_literature(); >>
3244    
3245    Return the literature for this subsystem.
3246    
3247    =cut
3248    
3249    sub get_literature
3250    {
3251        my($self) = @_;
3252    
3253        return $self->{literature};
3254    }
3255    
3256  =head3 get_reactions  =head3 get_reactions
3257    
3258  C<< my $reactHash = $sub->get_reactions(); >>  C<< my $reactHash = $sub->get_reactions(); >>
# Line 3411  Line 3517 
3517      $self->{notes} = $notes;      $self->{notes} = $notes;
3518  }  }
3519    
3520    sub set_description
3521    {
3522        my($self, $desc) = @_;
3523    
3524        $self->{description} = $desc;
3525    }
3526    
3527    sub set_literature
3528    {
3529        my($self, $lit) = @_;
3530    
3531        $self->{literature} = $lit;
3532    }
3533    
3534  sub get_classification  sub get_classification
3535  {  {
3536      my($self) = @_;      my($self) = @_;

Legend:
Removed from v.1.109  
changed lines
  Added in v.1.110

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3