[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.57, Fri Jul 29 18:13:45 2005 UTC revision 1.58, Fri Jul 29 19:31:21 2005 UTC
# Line 451  Line 451 
451      # Now load the rest of the info.      # Now load the rest of the info.
452      #      #
453    
454        $self->load_reactions();
455      $self->load_notes();      $self->load_notes();
456      $self->load_classification();      $self->load_classification();
457      $self->load_version();      $self->load_version();
# Line 465  Line 466 
466      $self->{notes} = &FIG::file_read(File::Spec->catfile($self->{dir}, "notes"));      $self->{notes} = &FIG::file_read(File::Spec->catfile($self->{dir}, "notes"));
467  }  }
468    
469    sub load_reactions
470    {
471        my($self) = @_;
472    
473        my $reactions = undef;
474        if (open(REACT,"<$self->{dir}/reactions"))
475        {
476            while (defined($_ = <REACT>))
477            {
478                if ($_ =~ /^(\S.*\S)\t(\S+)/)
479                {
480                    push(@{$reactions->{$1}},split(/,/,$2));
481                }
482            }
483            close(REACT);
484        }
485    
486        $self->{reactions} = $reactions;
487    }
488    
489    
490    
491    
492  sub load_classification  sub load_classification
493  {  {
494      my($self) = @_;      my($self) = @_;
# Line 712  Line 736 
736      my $ss_bak = "$dir/spreadsheet~";      my $ss_bak = "$dir/spreadsheet~";
737      my $notes_file = "$dir/notes";      my $notes_file = "$dir/notes";
738      my $notes_bak = "$dir/notes~";      my $notes_bak = "$dir/notes~";
739        my $reactions_file = "$dir/reactions";
740        my $reactions_bak = "$dir/reactions~";
741      my $classification_file = "$dir/CLASSIFICATION";      my $classification_file = "$dir/CLASSIFICATION";
742    
743      if (-f $ss_file)      if (-f $ss_file)
# Line 724  Line 750 
750          rename($notes_file, $notes_bak);          rename($notes_file, $notes_bak);
751      }      }
752    
753        if (-f $reactions_file)
754        {
755            rename($reactions_file, $reactions_bak) or warn "rename $reactions_file $reactions_bak failed $!";
756            print STDERR "wrote $reactions_bak\n";
757        }
758    
759      #      #
760      # Eval this whole chunk, so that if we get any fatal errors, we can      # Eval this whole chunk, so that if we get any fatal errors, we can
761      # roll back to the old saved data.      # roll back to the old saved data.
# Line 741  Line 773 
773          close($fh);          close($fh);
774          chmod(0777,$notes_file);          chmod(0777,$notes_file);
775    
776            open($fh, ">$reactions_file") or die "Cannot open $reactions_file for writing: $!\n";
777            my $reactions = $self->{reactions};
778            foreach $_ (sort keys(%$reactions))
779            {
780                print $fh "$_\t" . join(",", @{$reactions->{$_}}), "\n";
781            }
782            close($fh);
783            chmod(0777,$reactions_file);
784    
785          open($fh, ">$classification_file") or die "Can not open $classification_file for writing: $!\n";          open($fh, ">$classification_file") or die "Can not open $classification_file for writing: $!\n";
786          print $fh join "\t", (@{$self->{classification}}), "\n";          print $fh join "\t", (@{$self->{classification}}), "\n";
787          close($fh);          close($fh);
# Line 812  Line 853 
853      my $ss_bak = "$dir/spreadsheet~";      my $ss_bak = "$dir/spreadsheet~";
854      my $notes_file = "$dir/notes";      my $notes_file = "$dir/notes";
855      my $notes_bak = "$dir/notes~";      my $notes_bak = "$dir/notes~";
856        my $reactions_file = "$dir/reactions";
857        my $reactions_bak = "$dir/reactions~";
858    
859      my $ss_diff = abs((-s $ss_file) - (-s $ss_bak));      my $ss_diff = abs((-s $ss_file) - (-s $ss_bak));
860      my $notes_diff = abs((-s $notes_file) - (-s $notes_bak));      my $notes_diff = abs((-s $notes_file) - (-s $notes_bak));
861        my $reactions_diff = (system("cmp -s $reactions_file $reactions_bak") != 0);
862        print STDERR "reactions_file=$reactions_file reactions_bak=$reactions_bak dif=$reactions_diff\n";
863    
864      if (($ss_diff > 10) or ($notes_diff > 10))      if (($ss_diff > 10) or ($notes_diff > 10) or $reactions_diff)
865      {      {
866          $self->make_backup();          $self->make_backup();
867      }      }
# Line 835  Line 880 
880    
881      rename("$dir/spreadsheet~", "$bak/spreadsheet.$ts");      rename("$dir/spreadsheet~", "$bak/spreadsheet.$ts");
882      rename("$dir/notes~", "$bak/notes.$ts");      rename("$dir/notes~", "$bak/notes.$ts");
883        rename("$dir/reactions~", "$bak/reactions.$ts");
884      $self->{version}++;      $self->{version}++;
885  }  }
886    
# Line 1904  Line 1950 
1950      return $self->{notes};      return $self->{notes};
1951  }  }
1952    
1953    sub get_reactions
1954    {
1955        my($self) = @_;
1956    
1957        return $self->{reactions};
1958    }
1959    
1960  sub set_notes  sub set_notes
1961  {  {
1962      my($self, $notes) = @_;      my($self, $notes) = @_;

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.58

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3