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

Diff of /FigWebServices/cv.cgi

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

revision 1.6, Fri Oct 21 22:27:40 2005 UTC revision 1.15, Thu Nov 10 20:18:17 2005 UTC
# Line 10  Line 10 
10  use CGI;  use CGI;
11  use Tracer;  use Tracer;
12    
 print STDERR "NEW LOAD of PAGE\n";  
   
13  my $cgi = new CGI;  my $cgi = new CGI;
14    
15  use HTML;  use HTML;
# Line 76  Line 74 
74  my $ids;  my $ids;
75  my $tag_to_id;  my $tag_to_id;
76  my $inputs;  my $inputs;
 print STDERR "REQ: ", $cgi->param('request'), "\n";  
77    
78  if ($cgi->param('request') eq "Delete Checked Terms")  if ($cgi->param('request') eq "Delete Checked Terms")
79  {  {
80      print STDERR "HERE Delete Clicked\n";      if (!$cgi->param('user'))
81        {
82                my(@html);
83                push(@html, $cgi->p("You must be logged in as a user to edit controlled vocabulary terms."));
84                &HTML::show_page($cgi, \@html, 1);
85                exit;
86        }
87        else
88        {
89      my %id_term_to_source;      my %id_term_to_source;
90      my @checked;      my @checked;
91      my @param_list = $cgi->param();      my @param_list = $cgi->param();
# Line 93  Line 98 
98               if($cgi->param($p))               if($cgi->param($p))
99               {               {
100                   $value = $cgi->param($p);                   $value = $cgi->param($p);
                  print STDERR "delete_checked_value:$value\n";  
101                   push(@checked,$value)                   push(@checked,$value)
102               }               }
103            }            }
# Line 101  Line 105 
105    
106          for my $c (@checked)          for my $c (@checked)
107          {          {
            print STDERR "checked_for_deletion:$c\n";  
108             @temp = split('split_here',$c);             @temp = split('split_here',$c);
109             $id_term_to_source{$temp[1]} = $temp[0];             $id_term_to_source{$temp[1]} = $temp[0];
110          }          }
111      }      }
112      &delete_terms($fig,$cgi,$html,$peg,\%id_term_to_source);      &delete_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
113  }  }
114    }
115  elsif ($cgi->param('request') eq "Search Selected Controlled Vocabulary")  elsif ($cgi->param('request') eq "Search Selected Controlled Vocabulary")
116  {  {
117      if ( $cgi->param('search_term') && $cgi->param('select_cv') ) {      if ( $cgi->param('search_term') && $cgi->param('select_cv') ) {
118          $search_term=$cgi->param('search_term');          $search_term=$cgi->param('search_term');
119          $cv=$cgi->param('select_cv');          $cv=$cgi->param('select_cv');
120          $search_results = &search($fig,$cgi,$html,$peg,$cv,$search_term);          $search_results = $fig->search_cv_file($cv,$search_term);
121      }      }
122  }  }
123  elsif ($cgi->param('request') eq "Add New Terms")  elsif ($cgi->param('request') eq "Add New Terms")
124  {  {
125        if (!$cgi->param('user'))
126        {
127                my(@html);
128                push(@html, $cgi->p("You must be logged in as a user to edit controlled vocabulary terms."));
129                &HTML::show_page($cgi, \@html, 1);
130                exit;
131        }
132        else
133        {
134      my %id_term_to_source;      my %id_term_to_source;
135      my @checked;      my @checked;
136      my @param_list = $cgi->param();      my @param_list = $cgi->param();
# Line 127  Line 140 
140          {          {
141            if ( $p=~/add_checked/)            if ( $p=~/add_checked/)
142            {            {
               print STDERR "checked_param:$p\n";  
143               if($cgi->param($p))               if($cgi->param($p))
144               {               {
145                   $value = $cgi->param($p);                   $value = $cgi->param($p);
# Line 142  Line 154 
154             $source = $temp[0];             $source = $temp[0];
155             $id_term = $temp[1];             $id_term = $temp[1];
156             $id_term_to_source{$id_term} =$source ;             $id_term_to_source{$id_term} =$source ;
            print STDERR "checked_source:$source\n";  
            print STDERR "checked_value:$c\n";  
157          }          }
158      }      }
159      &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);      &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
160    
161  }  }
162    }
163    
164  elsif ($cgi->param('request') eq "Add Manual Term")  elsif ($cgi->param('request') eq "Add Term Manually")
165    {
166        if (!$cgi->param('user'))
167        {
168                my(@html);
169                push(@html, $cgi->p("You must be logged in as a user to edit controlled vocabulary terms."));
170                &HTML::show_page($cgi, \@html, 1);
171                exit;
172        }
173        else
174  {  {
175      my %id_term_to_source;      my %id_term_to_source;
176      my $id_term;      my $id_term;
# Line 158  Line 178 
178          $manual_source=$cgi->param('manual_source');          $manual_source=$cgi->param('manual_source');
179          $manual_id=$cgi->param('manual_id');          $manual_id=$cgi->param('manual_id');
180          $manual_term=$cgi->param('manual_term');          $manual_term=$cgi->param('manual_term');
181          $id_term = $manual_id.": ".$manual_term;              $id_term = $manual_id."; ".$manual_term;
182          $id_term_to_source{$id_term} = $manual_source;          $id_term_to_source{$id_term} = $manual_source;
183          &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);          &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
184      } else {          }
185            else
186            {
187          $error_message = "Error in 'Add Terms Manually': supply all three items correctly.";          $error_message = "Error in 'Add Terms Manually': supply all three items correctly.";
188      }      }
189  }  }
190    }
191  else  else
192  {  {
193      #no op.  Initial page display      #no op.  Initial page display
# Line 180  Line 203 
203     my @id_term = keys(%{$id_term_to_source});     my @id_term = keys(%{$id_term_to_source});
204     foreach my $it (@id_term)     foreach my $it (@id_term)
205     {     {
          print STDERR "key:$it\n";  
          print STDERR "value:$id_term_to_source->{$it}\n";  
206           $fig->delete_attribute($peg,$id_term_to_source->{$it},$it)           $fig->delete_attribute($peg,$id_term_to_source->{$it},$it)
207      }      }
208  }  }
209    
210  sub search  # moved to FIG.pm
211  {  #sub search_cv_file
212      my ($fig,$cgi,$html,$peg,$cv,$search_term) =@_;  #{
213      $file = $FIG_Config::global."/cv_search_".$cv.".txt";  ##    my ($fig,$cgi,$html,$peg,$cv,$search_term) =@_;
214      if (! open(LOOKUP,"$file") ) {  #    my ($cv,$search_term) =@_;
215          $error_message="Search could not find vocabulary file, $file";  #    $file = $FIG_Config::global."/CV/cv_search_".$cv.".txt";
216          return;  #    if (! open(LOOKUP,"$file") ) {
217      }  #       print STDERR "Search could not find vocabulary file, $file";
218      my @lines = <LOOKUP>;  #       return;
219      my @grep_results = grep(/$search_term/i,@lines);  #    }
220      print STDERR "$grep_results[0]\n";  #    my @lines = <LOOKUP>;
221      return [@grep_results];  #    my @grep_results = grep(/$search_term/i,@lines);
222      #my $search_results = [@grep_results];  #     return [@grep_results];
223      #&show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);  #}
 }  
224    
225  sub add_terms  sub add_terms
226  {  {
227        print STDERR "add_terms called!\n";
228      my ($fig,$cgi,$html,$peg,$id_term_to_source) =@_ ;      my ($fig,$cgi,$html,$peg,$id_term_to_source) =@_ ;
229      my @id_term = keys(%{$id_term_to_source});      my @id_term = keys(%{$id_term_to_source});
230        #my %sources={};   #in case someday we allow adds from >1 vocab at once
231        my $source;
232        my $user = $cgi->param('user');
233    
234      foreach my $it (@id_term)      foreach my $it (@id_term)
235      {      {
236          print STDERR "added_source:$id_term_to_source->{$it}\n";         $source = $id_term_to_source->{$it};
237          print STDERR "added_value:$it\n";         my @temp = split("; ",$it);
238           my $id = $temp[0];
239           my $term = $temp[1];
240           my $status = $fig->add_cv_term( $user, $peg, $source, $id, $term);
241           if (!$status) {
242               #print STDERR "$peg- Added ($source, $id, $term)\n";
243               #&HTML::show_page($cgi, \@html);
244           }
245           else
246           {
247               print STDERR "$peg- Error for ($source, $id, $term):\t$status\n";
248               my(@html);
249               push(@html, $cgi->p("$peg- Error for ($source, $id, $term):\t$status\n"));
250               &HTML::show_page($cgi, \@html, 1);
251               exit;
252            }
253    
         $fig->add_attribute($peg,$id_term_to_source->{$it},$it);  
254    
255      }      }
256    
257        #$sources{$source}=1;   #build unique list of source names
258    
259    
260    
261        #my %key_info_hash;
262        #$key_info_hash{"is_cv"} = 1;
263        #$key_info_hash{"single"} = 0;
264        #$key_info_hash{"readonly"} = 1;
265    
266        #$fig->key_info($source,\%key_info_hash);
267    
268      #&show_initial($fig,$cgi,$html,$peg);      #&show_initial($fig,$cgi,$html,$peg);
269  }  }
270    
# Line 227  Line 278 
278      # Build seach results table      # Build seach results table
279    
280      @sr = @$search_results;      @sr = @$search_results;
281      my $add_col_hdrs = ["Add","Source","ID: Term"];      my $add_col_hdrs = ["Add","Vocab. Name","ID; Term"];
282      my $add_table_rows;      my $add_table_rows;
283      my $counter = 0;      my $counter = 0;
284      for my $r (@sr)      for my $r (@sr)
# Line 237  Line 288 
288          $cv=$cgi->param('select_cv');          $cv=$cgi->param('select_cv');
289          $source = $cv;          $source = $cv;
290          $id= $temp[1];          $id= $temp[1];
         print STDERR "id:$id\n";  
291          $term = $temp[2];          $term = $temp[2];
292          print STDERR "term:$term\n";          $id_and_term = $id."; ".$term;
         $id_and_term = $id.": ".$term;  
293          $cb_value = $cv."split_here".$id."; ".$term;          $cb_value = $cv."split_here".$id."; ".$term;
         print STDERR "iandt:$id_and_term\n";  
294          $cb ="<input type=checkbox name=add_checked_$counter value='$cb_value'>" ;          $cb ="<input type=checkbox name=add_checked_$counter value='$cb_value'>" ;
295          push(@$row,$cb);          push(@$row,$cb);
296          push(@$row,$source);          push(@$row,$source);
# Line 258  Line 306 
306    
307      # build term deletions stuff      # build term deletions stuff
308    
309      my $delete_col_hdrs = ["Delete","Source","ID: Term"];      my $delete_col_hdrs = ["Delete","Vocab. Name","ID; Term"];
310      my @results = $fig->get_attributes($peg);      my @results = $fig->get_attributes($peg);
     print STDERR "@results\n";  
     print STDERR "peg:$peg\n";  
311      my $delete_table_rows;      my $delete_table_rows;
312      my $counter =0;      my $counter =0;
313      for my $r (@results)      for my $r (@results)
314      {      {
315          $row = [];          $row = [];
316          $source = $r->[1];          $source = $r->[1];
317          print STDERR "deleted_checked_source:$source\n";          $cv_key_hash = $fig->key_info($source);
318            if($cv_key_hash->{"is_cv"} == 1)
319            {
320          $id_and_term = $r->[2];          $id_and_term = $r->[2];
         print STDERR "deleted_id_and_term:$id_and_term\n";  
321          $value = $source."split_here".$id_and_term;          $value = $source."split_here".$id_and_term;
322          $cb ="<input type=checkbox name='delete_checked_$counter' value='$value'>" ;          $cb ="<input type=checkbox name='delete_checked_$counter' value='$value'>" ;
323          push(@$row,$cb);          push(@$row,$cb);
# Line 279  Line 326 
326          push(@$delete_table_rows,$row);          push(@$delete_table_rows,$row);
327          $counter = $counter + 1;          $counter = $counter + 1;
328      }      }
329        }
330    
331    
332      # build the page      # build the page
333        my $user = $cgi->param('user');
334      my $link = "protein.cgi?prot=$peg";      my $link = "protein.cgi?prot=$peg&user=$user";
335      push @$html,      push @$html,
336      #$cgi->start_multipart_form(),      #$cgi->start_multipart_form(),
337      $cgi->start_form(),      $cgi->start_form(),
# Line 311  Line 359 
359      "<h4>Search for New Terms to Add </h4>\n",      "<h4>Search for New Terms to Add </h4>\n",
360      "<select name=select_cv>      "<select name=select_cv>
361          <option value=GO  >Gene Ontology</option>          <option value=GO  >Gene Ontology</option>
362            <option value=HUGO  >HUGO Gene Nomenclature Committee</option>
363       </select> &nbsp;&nbsp",       </select> &nbsp;&nbsp",
364      $cgi->textfield(-name => 'search_term', -size => 20),      $cgi->textfield(-name => 'search_term', -size => 20),
365      $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),      $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),
# Line 326  Line 375 
375      $cgi->hidden(-name=>'prot', -value=>'$peg'),      $cgi->hidden(-name=>'prot', -value=>'$peg'),
376      $cgi->hidden(-name=>'user', -value=>'$user'),      $cgi->hidden(-name=>'user', -value=>'$user'),
377      $cgi->hr,      $cgi->hr,
378      "<h4>Add Terms Manually (WARNING: This is strongly discouraged to avoid data entry errors.)</h5>",      "<h4>Add Term Manually (WARNING: This is strongly discouraged to avoid data entry errors.)</h5>",
379      "<h5>Vocabulary Name (single word, no spaces or punctuation), e.g., MyVocab </h5>\n",      "<h5>Vocabulary Name (single word, no spaces or punctuation), e.g., MyVocab </h5>\n",
380      $cgi->textfield(-name => 'manual_source', -size => 48, -default=>'', -override=>1 ),      $cgi->textfield(-name => 'manual_source', -size => 48, -default=>'', -override=>1 ),
381      "<h5>Term ID (single word, no spaces or punctuation), e.g., A147</h5>\n",      "<h5>Term ID (single word, no spaces or punctuation), e.g., A147</h5>\n",
# Line 334  Line 383 
383      "<h5>Term text, e.g., catalytic activity</h5>\n",      "<h5>Term text, e.g., catalytic activity</h5>\n",
384      $cgi->textfield(-name => 'manual_term', -size => 70, -default=>'', -override=>1 ),      $cgi->textfield(-name => 'manual_term', -size => 70, -default=>'', -override=>1 ),
385      $cgi->br,$cgi->br,      $cgi->br,$cgi->br,
386      $cgi->submit(-name=>'request', -value=>'Add Manual Term'),      $cgi->submit(-name=>'request', -value=>'Add Term Manually'),
387      $cgi->br,      $cgi->br,
388      $cgi->hr,      $cgi->hr,
389      $cgi->end_form;      $cgi->end_form;

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3