[Bio] / FigWebServices / subsys.cgi Repository:
ViewVC logotype

Diff of /FigWebServices/subsys.cgi

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

revision 1.96, Thu Jul 28 20:50:05 2005 UTC revision 1.97, Fri Jul 29 19:31:21 2005 UTC
# Line 494  Line 494 
494      }      }
495      else      else
496      {      {
497            my @roles = $subsystem->get_roles;
498            my $reactions = $subsystem->get_reactions;
499            my($rparm,$vparm);
500            foreach $rparm (grep { $_ =~ /^react\d+/ } $cgi->param)
501            {
502                if ($vparm = $cgi->param($rparm))
503                {
504                    $rparm =~ /^react(\d+)/;
505                    my $roleN  = $1 - 1;
506                    $reactions->{$roles[$roleN]} = [split(",",$vparm)];
507                }
508            }
509    
510          my($role,$p,$abr,$r,$n);          my($role,$p,$abr,$r,$n);
511          my @tuplesR = ();          my @tuplesR = ();
512          my @roles   = grep { $_ =~ /^role/ }   $cgi->param();  
513    ###     NOTE: the meaning (order) or @roles shifts here to the NEW order
514            @roles   = grep { $_ =~ /^role/ }   $cgi->param();
515          if (@roles == 0)  { return 1 }     # initial call, everything is as it was          if (@roles == 0)  { return 1 }     # initial call, everything is as it was
516    
517          foreach $role (@roles)          foreach $role (@roles)
# Line 520  Line 535 
535                  }                  }
536              }              }
537          }          }
538          $subsystem->set_roles([map { [$_->[1],$_->[2]] } sort { $a->[0] <=> $b->[0] } @tuplesR]);          @tuplesR = sort { $a->[0] <=> $b->[0] } @tuplesR;
539            $subsystem->set_roles([map { [$_->[1],$_->[2]] } @tuplesR]);
540    
541          my($subset_name,$s,$test,$entries,$entry);          my($subset_name,$s,$test,$entries,$entry);
542          my @subset_names  = grep { $_ =~ /^nameCS/ } $cgi->param();          my @subset_names  = grep { $_ =~ /^nameCS/ } $cgi->param();
# Line 1147  Line 1162 
1162      my($fig,$cgi,$html,$subsystem,$can_alter) = @_;      my($fig,$cgi,$html,$subsystem,$can_alter) = @_;
1163      my($i);      my($i);
1164    
1165        my @roles = $subsystem->get_roles;
1166      my $sub_dir = $subsystem->get_dir;      my $sub_dir = $subsystem->get_dir;
1167    
1168      my $reactions = undef;      my $reactions = $subsystem->get_reactions;
1169      if (open(REACT,"<$sub_dir/reactions"))  
1170      {      my $n = 1;
1171          while (defined($_ = <REACT>))      my $col_hdrs = ["Column","Abbrev","Functional Role"];
1172    
1173        if ($reactions)
1174          {          {
1175              if ($_ =~ /^(\S.*\S)\t(\S+)/)          push(@$col_hdrs,"KEGG Reactions");
1176            if ($can_alter)
1177              {              {
1178                  push(@{$reactions->{$1}},split(/,/,$2));              push(@$col_hdrs,"Edit Reactions");
             }  
1179          }          }
         close(REACT);  
1180      }      }
1181    
     my $n = 1;  
     my $col_hdrs = $reactions ? ["Column","Abbrev","Functional Role","Reactions"] : ["Column","Abbrev","Functional Role"];  
1182      my $tab = [];      my $tab = [];
1183    
1184      &format_existing_roles($fig,$cgi,$html,$subsystem,$tab,\$n,$can_alter,$reactions);      &format_existing_roles($fig,$cgi,$html,$subsystem,$tab,\$n,$can_alter,$reactions,\@roles);
1185      if ($cgi->param('can_alter'))      if ($cgi->param('can_alter'))
1186      {      {
1187          for ($i=0; ($i < 5); $i++)          for ($i=0; ($i < 5); $i++)
# Line 1181  Line 1196 
1196  }  }
1197    
1198  sub format_existing_roles {  sub format_existing_roles {
1199      my($fig,$cgi,$html,$subsystem,$tab,$nP,$can_alter,$reactions) = @_;      my($fig,$cgi,$html,$subsystem,$tab,$nP,$can_alter,$reactions,$roles) = @_;
1200      my($role);      my($role);
1201    
1202      foreach $role ($subsystem->get_roles)      foreach $role (@$roles)
1203      {      {
1204          &format_role($fig,$cgi,$html,$subsystem,$tab,$$nP,$role,$can_alter,$reactions->{$role});          &format_role($fig,$cgi,$html,$subsystem,$tab,$$nP,$role,$can_alter,$reactions);
1205          $$nP++;          $$nP++;
1206      }      }
1207  }  }
1208    
1209  sub kegg_reaction_link {  sub reaction_link {
1210      my($reaction) = @_;      my($reaction) = @_;
1211    
1212      if ($reaction =~ /^R\d+/)      if ($reaction =~ /^R\d+/)
# Line 1205  Line 1220 
1220      my($fig,$cgi,$html,$subsystem,$tab,$n,$role,$can_alter,$reactions) = @_;      my($fig,$cgi,$html,$subsystem,$tab,$n,$role,$can_alter,$reactions) = @_;
1221      my($abbrev,$reactT);      my($abbrev,$reactT);
1222    
1223      my $react = $reactions ? join(",", map { &kegg_reaction_link($_) } @$reactions) : "";      my $react = $reactions ? join(",", map { &reaction_link($_) } @{$reactions->{$role}}) : "";
1224    
1225      $abbrev = $role ? $subsystem->get_role_abbr($subsystem->get_role_index($role)) : "";      $abbrev = $role ? $subsystem->get_role_abbr($subsystem->get_role_index($role)) : "";
1226    
# Line 1215  Line 1230 
1230          $posT = $cgi->textfield(-name => "posR$n", -size => 3, -value => $n, -override => 1);          $posT = $cgi->textfield(-name => "posR$n", -size => 3, -value => $n, -override => 1);
1231          $abbrevT = $cgi->textfield(-name => "abbrev$n", -size => 7, -value => $abbrev, -override => 1);          $abbrevT = $cgi->textfield(-name => "abbrev$n", -size => 7, -value => $abbrev, -override => 1);
1232          $roleT = $cgi->textfield(-name => "role$n", -size => 80, -value => $role, -override => 1);          $roleT = $cgi->textfield(-name => "role$n", -size => 80, -value => $role, -override => 1);
1233          $reactT = $react;          $reactT  = $cgi->textfield(-name => "react$n", -size => 20, -value => "", -override => 1);
1234      }      }
1235      else      else
1236      {      {
# Line 1225  Line 1240 
1240          $posT = $n;          $posT = $n;
1241          $abbrevT = $abbrev;          $abbrevT = $abbrev;
1242          $roleT = $role;          $roleT = $role;
         $reactT = $react;  
1243      }      }
1244      #      #
1245      # Wrap the first element in the table with a <A NAME="role_rolename"> tag      # Wrap the first element in the table with a <A NAME="role_rolename"> tag
# Line 1242  Line 1256 
1256          $posT_html = "<a name=\"$rn\">$posT</a>";          $posT_html = "<a name=\"$rn\">$posT</a>";
1257      }      }
1258    
1259        my $row = [$posT_html,$abbrevT,$roleT];
1260      push(@$tab,[$posT_html,$abbrevT,$roleT,$reactT]);      if ($reactions)
1261        {
1262            push(@$row,$react);
1263            if ($can_alter)
1264            {
1265                push(@$row,$reactT);
1266            }
1267        }
1268        push(@$tab,$row);
1269    
1270      if ($cgi->param('check_problems'))      if ($cgi->param('check_problems'))
1271      {      {
# Line 2960  Line 2982 
2982              chmod(0777,"$FIG_Config::data/Subsystems/$ssa/notes");              chmod(0777,"$FIG_Config::data/Subsystems/$ssa/notes");
2983          }          }
2984    
2985            if (-s "$FIG_Config::data/Subsystems/$ssa/Backup/reactions.$ts")
2986            {
2987                system "cp -f $FIG_Config::data/Subsystems/$ssa/Backup/reactions.$ts $FIG_Config::data/Subsystems/$ssa/reactions";
2988                chmod(0777,"$FIG_Config::data/Subsystems/$ssa/reactions");
2989            }
2990    
2991          my $subsystem = new Subsystem($ssa,$fig,0);          my $subsystem = new Subsystem($ssa,$fig,0);
2992          $subsystem->db_sync(0);          $subsystem->db_sync(0);
2993          undef $subsystem;          undef $subsystem;

Legend:
Removed from v.1.96  
changed lines
  Added in v.1.97

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3