[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.9, Tue Oct 25 01:56:45 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 119  Line 117 
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")
# Line 163  Line 161 
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'))      if (!$cgi->param('user'))
167      {      {
# Line 180  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          }          }
# Line 209  Line 207 
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       return [@grep_results];  #    my @lines = <LOOKUP>;
221      #my $search_results = [@grep_results];  #    my @grep_results = grep(/$search_term/i,@lines);
222      #&show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);  #     return [@grep_results];
223  }  #}
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      #my %sources={};   #in case someday we allow adds from >1 vocab at once
231      my $source;      my $source;
232        my $user = $cgi->param('user');
233    
234      foreach my $it (@id_term)      foreach my $it (@id_term)
235      {      {
236         $source = $id_term_to_source->{$it};         $source = $id_term_to_source->{$it};
237         $fig->add_attribute($peg,$source,$it);         my @temp = split("; ",$it);
238         $sources{$source}=1;   #build unique list of source names         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    
254    
255       }
256    
257        #$sources{$source}=1;   #build unique list of source names
258    
259    
260    
261      my %key_info_hash;      #my %key_info_hash;
262      $key_info_hash{"is_cv"} = 1;      #$key_info_hash{"is_cv"} = 1;
263      $key_info_hash{"single"} = 0;      #$key_info_hash{"single"} = 0;
264      $key_info_hash{"readonly"} = 1;      #$key_info_hash{"readonly"} = 1;
265    
266      $fig->key_info($source,\%key_info_hash);      #$fig->key_info($source,\%key_info_hash);
267    
268      #&show_initial($fig,$cgi,$html,$peg);      #&show_initial($fig,$cgi,$html,$peg);
269  }  }
# Line 257  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 268  Line 289 
289          $source = $cv;          $source = $cv;
290          $id= $temp[1];          $id= $temp[1];
291          $term = $temp[2];          $term = $temp[2];
292          $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;
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);
# Line 285  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);
311      my $delete_table_rows;      my $delete_table_rows;
312      my $counter =0;      my $counter =0;
# Line 317  Line 338 
338      $cgi->hidden(-name=>'prot', -value=>'$peg'),      $cgi->hidden(-name=>'prot', -value=>'$peg'),
339      $cgi->hidden(-name=>'user', -value=>'$user'),      $cgi->hidden(-name=>'user', -value=>'$user'),
340      $cgi->br,      $cgi->br,
341      "<a href=$link Back to protein page</a>",      "<a href=$link> Back to protein page</a>",
342      $cgi->br,      $cgi->br,
343      "<h2>Controlled Vocabulary Workbench for $peg</h2>",      "<h2>Controlled Vocabulary Workbench for $peg</h2>",
344      $cgi->hr,      $cgi->hr,
# Line 338  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 353  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 361  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.9  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3