[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.13, Wed Oct 27 16:15:28 2004 UTC revision 1.14, Sat Oct 30 23:58:47 2004 UTC
# Line 57  Line 57 
57  my $user = $cgi->param('user');  my $user = $cgi->param('user');
58  $fig->set_user($user);  $fig->set_user($user);
59    
60  if ((! $user) || ($user !~ /^master:\S+/))  if ($cgi->param('resynch_peg_connections') && (my $ssa = $cgi->param('ssa_name')))
 {  
     push(@$html,$cgi->h1("Sorry, you need to specify a master user to modify subsystem annotations"));  
 }  
 elsif ($cgi->param('resynch_peg_connections') && (my $ssa = $cgi->param('ssa_name')))  
61  {  {
62      my $subsystem = new Subsystem($ssa,$fig,0);      my $subsystem = new Subsystem($ssa,$fig,0);
63      $subsystem->db_sync(0);      $subsystem->db_sync(0);
64      undef $subsystem;      undef $subsystem;
65      &one_cycle($fig,$cgi,$html);      &one_cycle($fig,$cgi,$html);
66  }  }
67  elsif ($cgi->param("extend_with_billogix"))  elsif ($user && ($cgi->param("extend_with_billogix")))
68  {  {
69      #      #
70      # Start a bg task to extend the subsystem.      # Start a bg task to extend the subsystem.
# Line 80  Line 76 
76    
77      my $sub = $fig->get_subsystem($ssa);      my $sub = $fig->get_subsystem($ssa);
78    
79      if ($sub)      if ($sub && ($user eq $sub->get_curator))
80      {      {
81          #          #
82          # See if there's already an extend job running.          # See if there's already an extend job running.
# Line 120  Line 116 
116  {  {
117      $request = defined($request) ? $request : "";      $request = defined($request) ? $request : "";
118    
119      if    ($request eq "reset")      if    (($request eq "reset") && $user)
120      {      {
121          &reset_ssa($fig,$cgi,$html);        # allow user to go back to a previous version of the ss          &reset_ssa($fig,$cgi,$html);        # allow user to go back to a previous version of the ss
122      }      }
123      elsif    ($request eq "reset_to")      elsif    (($request eq "reset_to") && $user)
124      {      {
125          &reset_ssa_to($fig,$cgi,$html);     # this actually resets to the previous version          &reset_ssa_to($fig,$cgi,$html);     # this actually resets to the previous version
126          &one_cycle($fig,$cgi,$html);          &one_cycle($fig,$cgi,$html);
127      }      }
128      elsif    ($request eq "make_exchangable")      elsif    (($request eq "make_exchangable") && $user)
129      {      {
130          &make_exchangable($fig,$cgi,$html);          &make_exchangable($fig,$cgi,$html);
131          &show_initial($fig,$cgi,$html);          &show_initial($fig,$cgi,$html);
132      }      }
133      elsif    ($request eq "make_unexchangable")      elsif    (($request eq "make_unexchangable") && $user)
134      {      {
135          &make_unexchangable($fig,$cgi,$html);          &make_unexchangable($fig,$cgi,$html);
136          &show_initial($fig,$cgi,$html);          &show_initial($fig,$cgi,$html);
# Line 149  Line 145 
145      # here based on $cgi->param('delete_export') - the original button,      # here based on $cgi->param('delete_export') - the original button,
146      # or $cgi->param('publish') - the new one.      # or $cgi->param('publish') - the new one.
147      #      #
148      elsif ($request eq "delete_or_export_ssa" and      elsif (($request eq "delete_or_export_ssa") && $user &&
149             defined($cgi->param('delete_export')))             defined($cgi->param('delete_export')))
150      {      {
151          my($ssa,$exported);          my($ssa,$exported);
# Line 189  Line 185 
185              exit;              exit;
186          }          }
187      }      }
188      elsif ($request eq "delete_or_export_ssa" and      elsif (($request eq "delete_or_export_ssa") && $user &&
189             defined($cgi->param('publish')))             defined($cgi->param('publish')))
190      {      {
191          my($ssa,$exported);          my($ssa,$exported);
# Line 221  Line 217 
217          }          }
218          exit;          exit;
219      }      }
220      elsif (($request eq "new_ssa") && ($cgi->param('copy_from1')) && (! $cgi->param('cols_to_take1')))      elsif ($user && ($request eq "new_ssa") && ($cgi->param('copy_from1')) && (! $cgi->param('cols_to_take1')))
221      {      {
222          my $user = $cgi->param('user');          my $user = $cgi->param('user');
223          my $name = $cgi->param('ssa_name');          my $name = $cgi->param('ssa_name');
# Line 397  Line 393 
393      my $user = $cgi->param('user');      my $user = $cgi->param('user');
394      my $ssa  = $cgi->param('ssa_name');      my $ssa  = $cgi->param('ssa_name');
395    
     if  (! $user)  
     {  
         push(@$html,$cgi->h1('You need to specify a user to work on a subsystem annotation'));  
         return;  
     }  
   
396      if  (! $ssa)      if  (! $ssa)
397      {      {
398          push(@$html,$cgi->h1('You need to specify a subsystem'));          push(@$html,$cgi->h1('You need to specify a subsystem'));
# Line 414  Line 404 
404      {      {
405          &process_spreadsheet_changes($fig,$subsystem,$cgi,$html);          &process_spreadsheet_changes($fig,$subsystem,$cgi,$html);
406    
407            if ($cgi->param('can_alter') && ($user = $cgi->param('user')) && ($user eq $subsystem->get_curator))
408            {
409          $subsystem->write_subsystem();          $subsystem->write_subsystem();
410            }
411          &produce_html_to_display_subsystem($fig,$subsystem,$cgi,$html);          &produce_html_to_display_subsystem($fig,$subsystem,$cgi,$html);
412      }      }
413  }  }
414    
415  sub handle_role_and_subset_changes {  sub handle_role_and_subset_changes {
416      my($fig,$subsystem,$cgi,$html) = @_;      my($fig,$subsystem,$cgi,$html) = @_;
417        my $user;
418    
419      if (! $cgi->param('can_alter'))      if ((! $cgi->param('can_alter')) || (! ($user = $cgi->param('user'))) || ($user ne $subsystem->get_curator))
420      {      {
421          return 1;    # no changes, so...          return 1;    # no changes, so...
422      }      }
# Line 531  Line 525 
525  sub process_spreadsheet_changes {  sub process_spreadsheet_changes {
526      my($fig,$subsystem,$cgi,$html) = @_;      my($fig,$subsystem,$cgi,$html) = @_;
527    
528      if (! $cgi->param('can_alter'))      my $user;
529        if ((! $cgi->param('can_alter')) || (! ($user = $cgi->param('user'))) || ($user ne $subsystem->get_curator))
530      {      {
531          return 1;    # no changes, so...          return 1;    # no changes, so...
532      }      }
# Line 658  Line 653 
653    
654      my $user = $cgi->param('user');      my $user = $cgi->param('user');
655      my $ssa  = $cgi->param('ssa_name');      my $ssa  = $cgi->param('ssa_name');
656      my $can_alter = $cgi->param('can_alter');      my $can_alter = ($cgi->param('can_alter') && $user && ($user eq $subsystem->get_curator));
657    
658      my $name  = $ssa;      my $name  = $ssa;
659      $name =~ s/_/ /g;      $name =~ s/_/ /g;
# Line 674  Line 669 
669                   $cgi->br,                   $cgi->br,
670           );           );
671    
672      &format_roles($fig,$cgi,$html,$subsystem);      &format_roles($fig,$cgi,$html,$subsystem,$can_alter);
673      &format_subsets($fig,$cgi,$html,$subsystem);      &format_subsets($fig,$cgi,$html,$subsystem,$can_alter);
674      &format_rows($fig,$cgi,$html,$subsystem);      &format_rows($fig,$cgi,$html,$subsystem);
675    
676      if ($can_alter)      if ($can_alter)
# Line 719  Line 714 
714                  $cgi->br.$cgi->br                  $cgi->br.$cgi->br
715          );          );
716    
717        if ($can_alter)
718        {
719      push(@$html,$cgi->checkbox(-name => 'refill', -value => 1, -checked => 0, -override => 1,-label => 'refill spreadsheet from scratch'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'refill', -value => 1, -checked => 0, -override => 1,-label => 'refill spreadsheet from scratch'),$cgi->br);
720        }
721    
722      push(@$html,$cgi->checkbox(-name => 'show_dups', -value => 1, -checked => 0, -override => 1,-label => 'show duplicates'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'show_dups', -value => 1, -checked => 0, -override => 1,-label => 'show duplicates'),$cgi->br);
723      push(@$html,$cgi->checkbox(-name => 'check_problems', -value => 1, -checked => 0, -override => 1,-label => 'show PEGs in roles that do not match precisely'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'check_problems', -value => 1, -checked => 0, -override => 1,-label => 'show PEGs in roles that do not match precisely'),$cgi->br);
724        if ($can_alter)
725        {
726      push(@$html,$cgi->checkbox(-name => 'add_solid', -value => 1, -checked => 0, -override => 1,-label => 'Add Genomes with Solid Hits'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'add_solid', -value => 1, -checked => 0, -override => 1,-label => 'Add Genomes with Solid Hits'),$cgi->br);
727        }
728    
729      push(@$html,$cgi->checkbox(-name => 'show_coupled_fast', -value => 1, -checked => 0, -override => 1,-label => 'show coupled PEGs fast [depends on existing pins/clusters]'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'show_coupled_fast', -value => 1, -checked => 0, -override => 1,-label => 'show coupled PEGs fast [depends on existing pins/clusters]'),$cgi->br);
730      push(@$html,$cgi->checkbox(-name => 'show_coupled', -value => 1, -checked => 0, -override => 1,-label => 'show coupled PEGs[figure 2 minutes per PEG in spreadsheet]'),$cgi->br);      push(@$html,$cgi->checkbox(-name => 'show_coupled', -value => 1, -checked => 0, -override => 1,-label => 'show coupled PEGs[figure 2 minutes per PEG in spreadsheet]'),$cgi->br);
731      push(@$html,$cgi->br,"Align column: ",      push(@$html,$cgi->br,"Align column: ",
# Line 752  Line 755 
755      }      }
756    
757      my $notes = $subsystem->get_notes();      my $notes = $subsystem->get_notes();
758        if ($can_alter)
759        {
760      push(@$html,$cgi->hr,"NOTES:\n",$cgi->br,$cgi->textarea(-name => 'notes', -rows => 40, -cols => 100, -value => $notes));      push(@$html,$cgi->hr,"NOTES:\n",$cgi->br,$cgi->textarea(-name => 'notes', -rows => 40, -cols => 100, -value => $notes));
761        }
762        elsif ($notes)
763        {
764            push(@$html,$cgi->h2('notes'),"<pre>$notes</pre>");
765        }
766    
767      push(@$html, $cgi->end_form);      push(@$html, $cgi->end_form);
768    
# Line 817  Line 827 
827  }  }
828    
829  sub format_roles {  sub format_roles {
830      my($fig,$cgi,$html,$subsystem) = @_;      my($fig,$cgi,$html,$subsystem,$can_alter) = @_;
831      my($i);      my($i);
832    
833      my $col_hdrs = ["Column","Abbrev","Functional Role"];      my $col_hdrs = ["Column","Abbrev","Functional Role"];
834      my $tab = [];      my $tab = [];
835    
836      my $n = 1;      my $n = 1;
837      &format_existing_roles($fig,$cgi,$html,$subsystem,$tab,\$n);      &format_existing_roles($fig,$cgi,$html,$subsystem,$tab,\$n,$can_alter);
838      if ($cgi->param('can_alter'))      if ($cgi->param('can_alter'))
839      {      {
840          for ($i=0; ($i < 5); $i++)          for ($i=0; ($i < 5); $i++)
# Line 839  Line 849 
849  }  }
850    
851  sub format_existing_roles {  sub format_existing_roles {
852      my($fig,$cgi,$html,$subsystem,$tab,$nP) = @_;      my($fig,$cgi,$html,$subsystem,$tab,$nP,$can_alter) = @_;
853      my($role);      my($role);
854    
855      foreach $role ($subsystem->get_roles)      foreach $role ($subsystem->get_roles)
856      {      {
857          &format_role($fig,$cgi,$html,$subsystem,$tab,$$nP,$role);          &format_role($fig,$cgi,$html,$subsystem,$tab,$$nP,$role,$can_alter);
858          $$nP++;          $$nP++;
859      }      }
860  }  }
861    
862  sub format_role {  sub format_role {
863      my($fig,$cgi,$html,$subsystem,$tab,$n,$role) = @_;      my($fig,$cgi,$html,$subsystem,$tab,$n,$role,$can_alter) = @_;
864      my($abbrev);      my($abbrev);
865    
866      $abbrev = $role ? $subsystem->get_role_abbr($subsystem->get_role_index($role)) : "";      $abbrev = $role ? $subsystem->get_role_abbr($subsystem->get_role_index($role)) : "";
867    
868      my($posT,$abbrevT,$roleT);      my($posT,$abbrevT,$roleT);
869      if ($cgi->param('can_alter'))      if ($can_alter)
870      {      {
871          $posT = $cgi->textfield(-name => "posR$n", -size => 3, -value => $n, -override => 1);          $posT = $cgi->textfield(-name => "posR$n", -size => 3, -value => $n, -override => 1);
872          $abbrevT = $cgi->textfield(-name => "abbrev$n", -size => 7, -value => $abbrev, -override => 1);          $abbrevT = $cgi->textfield(-name => "abbrev$n", -size => 7, -value => $abbrev, -override => 1);
# Line 918  Line 928 
928  }  }
929    
930  sub format_subsets {  sub format_subsets {
931      my($fig,$cgi,$html,$subsystem) = @_;      my($fig,$cgi,$html,$subsystem,$can_alter) = @_;
932    
933      &format_subsetsC($fig,$cgi,$html,$subsystem);      &format_subsetsC($fig,$cgi,$html,$subsystem,$can_alter);
934      &format_subsetsR($fig,$cgi,$html,$subsystem);      &format_subsetsR($fig,$cgi,$html,$subsystem);
935  }  }
936    
937  sub format_subsetsC {  sub format_subsetsC {
938      my($fig,$cgi,$html,$subsystem) = @_;      my($fig,$cgi,$html,$subsystem,$can_alter) = @_;
939    
940      my $col_hdrs = ["Subset","Includes These Roles"];      my $col_hdrs = ["Subset","Includes These Roles"];
941      my $tab = [];      my $tab = [];
942    
943      my $n = 1;      my $n = 1;
944      &format_existing_subsetsC($cgi,$html,$subsystem,$tab,\$n);      &format_existing_subsetsC($cgi,$html,$subsystem,$tab,\$n,$can_alter);
945    
946      if ($cgi->param('can_alter'))      if ($can_alter)
947      {      {
948          my $i;          my $i;
949          for ($i=0; ($i < 5); $i++)          for ($i=0; ($i < 5); $i++)
# Line 984  Line 994 
994  }  }
995    
996  sub format_existing_subsetsC {  sub format_existing_subsetsC {
997      my($cgi,$html,$subsystem,$tab,$nP) = @_;      my($cgi,$html,$subsystem,$tab,$nP,$can_alter) = @_;
998      my($nameCS);      my($nameCS);
999    
1000      foreach $nameCS (sort $subsystem->get_subset_namesC)      foreach $nameCS (sort $subsystem->get_subset_namesC)
# Line 1008  Line 1018 
1018    
1019          my($posT,$subsetT);          my($posT,$subsetT);
1020    
         if ($cgi->param('can_alter'))  
         {  
1021              $posT    = $cgi->textfield(-name => "nameCS$n", -size => 30, -value => $nameCS, -override => 1);              $posT    = $cgi->textfield(-name => "nameCS$n", -size => 30, -value => $nameCS, -override => 1);
1022              $subsetT = $cgi->textfield(-name => "subsetC$n", -size => 80, -value => $subset, -override => 1);              $subsetT = $cgi->textfield(-name => "subsetC$n", -size => 80, -value => $subset, -override => 1);
1023              push(@$tab,[$posT,$subsetT]);              push(@$tab,[$posT,$subsetT]);
1024          }          }
         elsif ($subset)  
         {  
             push(@$html,$cgi->hidden(-name => "nameCS$n", -value => $nameCS, -override => 1),  
                         $cgi->hidden(-name => "subsetC$n", -value => $subset, -override => 1));  
             $posT = $nameCS;  
             $subsetT = $subset;  
             push(@$tab,[$posT,$subsetT]);  
         }  
     }  
1025  }  }
1026    
1027  sub tree_link {  sub tree_link {
# Line 1616  Line 1615 
1615           $cgi->hidden(-name => 'user', -value => $user, -override => 1),           $cgi->hidden(-name => 'user', -value => $user, -override => 1),
1616           $cgi->hidden(-name => 'can_alter', -value => $can_alter, -override => 1));           $cgi->hidden(-name => 'can_alter', -value => $can_alter, -override => 1));
1617    
1618        my $just_role = &which_role($subsystem,$cgi->param('just_role'));
1619    
1620      foreach $org (@subsetR)      foreach $org (@subsetR)
1621      {      {
1622          my @missing = &columns_missing_entries($cgi,$subsystem,$org,\@subsetC,\%in);          my @missing = &columns_missing_entries($cgi,$subsystem,$org,\@subsetC,\%in);
1623          $missing = [];          $missing = [];
1624          foreach $role (@missing)          foreach $role (@missing)
1625          {          {
1626              next if (($_ = $cgi->param('just_role')) && ($_ != ($subsystem->get_role_index($role) + 1)));  #           next if (($_ = $cgi->param('just_role')) && ($_ != ($subsystem->get_role_index($role) + 1)));
1627                next if ($just_role && ($just_role ne $role));
1628    
1629              my @hits = $fig->find_role_in_org($role, $org, $user, $cgi->param("sims_cutoff"));              my @hits = $fig->find_role_in_org($role, $org, $user, $cgi->param("sims_cutoff"));
1630              push(@$missing,@hits);              push(@$missing,@hits);
# Line 2131  Line 2133 
2133          unlink("$FIG_Config::data/Subsystems/$ssa/EXCHANGABLE");          unlink("$FIG_Config::data/Subsystems/$ssa/EXCHANGABLE");
2134      }      }
2135  }  }
2136    
2137    sub which_role {
2138        my($subsystem,$role_indicator) = @_;
2139        my($n,$role,$abbr);
2140    
2141        if (($role_indicator =~ /^\s*(\d+)\s*$/) && ($n = $1) && ($role = $subsystem->get_role($n-1)))
2142        {
2143            return $role;
2144        }
2145        elsif (($role_indicator =~ /^\s*(\S+)\s*$/) && ($abbr = $1) && ($role = $subsystem->get_role_from_abbr($abbr)))
2146        {
2147            return $role;
2148        }
2149        return "";
2150    }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3