[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.2, Wed Oct 19 20:20:07 2005 UTC revision 1.3, Thu Oct 20 00:26:29 2005 UTC
# Line 18  Line 18 
18    
19  use LWP::Simple qw(!head); # see the caveat in perldoc LWP about importing two head methods.  use LWP::Simple qw(!head); # see the caveat in perldoc LWP about importing two head methods.
20    
 #for testing  
21    
22  my $peg = $cgi->param('prot');  my $peg;
23  #my $peg = "fig|9598.2.peg.1";  if ($cgi->param('prot') ) {
24        $peg = $cgi->param('prot');
25    } else {
26        $peg = $cgi->param('prot');
27        my(@html);
28        push(@html, $cgi->p("Parameter error- prot is required."));
29        &HTML::show_page($cgi, \@html, 1);
30        exit;
31    }
32    
33    # a global for the results of a search. overridden by an actual search
34    
35    my $search_results= [];
36    
37    my $custom_term_error = "";
38    
39    
40    my $user = "";
41    if ($cgi->param('user') ) {
42        $user = $cgi->param('user');
43    }
44    
45  my $fig;  my $fig;
46  eval {  eval {
# Line 48  Line 67 
67  }  }
68    
69  my $html = [];  my $html = [];
 my $user = $cgi->param('user');  
   
 unshift(@$html, "<TITLE>Controlled Vocabulary Workbench</TITLE>\n");  
70    
71  my $ids;  my $ids;
72  my $tag_to_id;  my $tag_to_id;
# Line 85  Line 101 
101  }  }
102  elsif ($cgi->param('request') eq "Search Selected Controlled Vocabulary")  elsif ($cgi->param('request') eq "Search Selected Controlled Vocabulary")
103  {  {
104      if ($cgi->param('search_term')) {$search_term=$cgi->param('search_term')}      if ( $cgi->param('search_term') && $cgi->param('select_cv') ) {
105      if ($cgi->param('select_cv')) {$cv=$cgi->param('select_cv')}          $search_term=$cgi->param('search_term');
106      &search($fig,$cgi,$html,$peg,$cv,$search_term);          $cv=$cgi->param('select_cv');
107            $search_results = &search($fig,$cgi,$html,$peg,$cv,$search_term);
108        }
109  }  }
110  elsif ($cgi->param('request') eq "Add New Terms")  elsif ($cgi->param('request') eq "Add New Terms")
111  {  {
# Line 127  Line 145 
145  {  {
146      my %id_term_to_source;      my %id_term_to_source;
147      my $id_term;      my $id_term;
148      if ($cgi->param('custom_source')) {$custom_source=$cgi->param('custom_source')}      if ( $cgi->param('custom_source') && $cgi->param('custom_id') && $cgi->param('custom_term') ) {
149      if ($cgi->param('custom_id')) {$custom_id=$cgi->param('custom_id')}          $custom_source=$cgi->param('custom_source');
150      if ($cgi->param('custom_term')) {$custom_term=$cgi->param('custom_term')}          $custom_id=$cgi->param('custom_id');
151            $custom_term=$cgi->param('custom_term');
152      $id_term = $custom_id.": ".$custom_term;      $id_term = $custom_id.": ".$custom_term;
153      $id_term_to_source{$id_term} = $custom_source;      $id_term_to_source{$id_term} = $custom_source;
154      &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);      &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
155        } else {
156            $custom_term_error = "Error: supply all three items correctly.";
157        }
158  }  }
   
159  else  else
160  {  {
161    &show_initial($fig,$cgi,$html,$peg);      my(@html);
162        push(@html, $cgi->p("Program error- unexpected request or logic error."));
163        &HTML::show_page($cgi, \@html, 1);
164        exit;
165  }  }
166    
167    &build_page($fig,$cgi,$html,$peg,$search_results);
168  &HTML::show_page($cgi,$html,1);  &HTML::show_page($cgi,$html,1);
169  exit;  exit;
170    
# Line 148  Line 173 
173     my ($fig,$cgi,$html,$peg,$id_term_to_source) = @_;     my ($fig,$cgi,$html,$peg,$id_term_to_source) = @_;
174     my @id_term = keys(%{$id_term_to_source});     my @id_term = keys(%{$id_term_to_source});
175     foreach my $it (@id_term){$fig->delete_attribute($peg,$id_term_to_source->{$it},$it)}     foreach my $it (@id_term){$fig->delete_attribute($peg,$id_term_to_source->{$it},$it)}
    &show_initial($fig,$cgi,$html,$peg);  
176  }  }
177    
178  sub search  sub search
# Line 159  Line 183 
183      my @lines = <LOOKUP>;      my @lines = <LOOKUP>;
184      my @grep_results = grep(/$search_term/i,@lines);      my @grep_results = grep(/$search_term/i,@lines);
185      print STDERR "$grep_results[0]\n";      print STDERR "$grep_results[0]\n";
186      my $search_results = [@grep_results];      return [@grep_results];
187      &show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);      #my $search_results = [@grep_results];
188        #&show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);
189  }  }
190    
191  sub add_terms  sub add_terms
# Line 175  Line 200 
200          $fig->add_attribute($peg,$id_term_to_source->{$it},$it);          $fig->add_attribute($peg,$id_term_to_source->{$it},$it);
201    
202      }      }
203      &show_initial($fig,$cgi,$html,$peg);      #&show_initial($fig,$cgi,$html,$peg);
204  }  }
205    
206  sub show_search_results {  
207   my ($fig,$cgi,$html,$peg,$cv,$search_results)=@_;  sub build_page {
208        my ($fig,$cgi,$html,$peg,$search_results)=@_;
209    
210    
211        unshift(@$html, "<TITLE>Controlled Vocabulary Workbench for $peg</TITLE>\n");
212    
213        # Build seach results table
214    
215   @sr = @$search_results;   @sr = @$search_results;
216   my $add_col_hdrs = ["Add","Source","ID: Term"];   my $add_col_hdrs = ["Add","Source","ID: Term"];
217   my $add_table_rows;   my $add_table_rows;
# Line 188  Line 220 
220   {   {
221       @temp = split("\t",$r);       @temp = split("\t",$r);
222       $row = [];       $row = [];
223            $cv=$cgi->param('select_cv');
224       $source = $cv;       $source = $cv;
225       $id= $temp[1];       $id= $temp[1];
226       print STDERR "id:$id\n";       print STDERR "id:$id\n";
# Line 204  Line 237 
237       $counter = $counter + 1;       $counter = $counter + 1;
238   }   }
239    
240   my $delete_col_hdrs = ["Delete","Source","ID: Term"];      my $add_terms_button="";
241   my @results = $fig->get_attributes($peg,'GO');      if ($counter > 0) {
242   my $delete_table_rows;          $add_terms_button= $cgi->submit(-name=>'request', -value=>'Add New Terms');
  $counter = 0;  
  for my $r (@results)  
  {  
      $row = [];  
      $source = $r->[1];  
   
      $id_and_term = $r->[2];  
      $cb ="<input type=checkbox name=delete_checked_$counter value=$id_and_term>" ;  
      push(@$row,$cb);  
      push(@$row,$source);  
      push(@$row,$id_and_term);  
      push(@$delete_table_rows,$row);  
      $counter = $counter + 1;  
  }  
   
  push @$html,  
  $cgi->start_multipart_form(),  
  "<h2>Controlled Vocabulary Workbench</h2>\n",  
  $cgi->hr,  
  "<h4>Current Terms Assigned To Peg </h4>\n",  
  &HTML::make_table($delete_col_hdrs,$delete_table_rows),  
  $cgi->br,  
  $cgi->submit(-name=>'request', -value=>'Delete Checked Terms'),  
  $cgi->hr,  
  $cgi->br,  
  "<h4>Search for New Terms to Add </h4>\n",  
  "<select name=select_cv>  
         <option value=go  >Gene Ontology</option>  
   </select> &nbsp;&nbsp",  
  $cgi->textfield(-name => "search_term", -size => 20),  
  $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),  
  $cgi->br,  
  &HTML::make_table($add_col_hdrs,$add_table_rows),  
  $cgi->br,  
  $cgi->submit(-name=>'request', -value=>'Add New Terms'),  
  $cgi->hr,  
  $cgi->br,  
  "<h4>Add Custom Terms </h4>\n",  
  "<h5>Source </h5>\n",  
  $cgi->textfield(-name => "custom_source", -size => 20),  
  "<h5>ID</h5>\n",  
  $cgi->textfield(-name => "custom_id", -size => 20),  
  "<h5>Term</h5>\n",  
  $cgi->textfield(-name => "custom_term", -size => 20),  
  $cgi->br,$cgi->br,  
  $cgi->submit(-name=>'request', -value=>'Add Custom Term'),  
  $cgi->br,  
  $cgi->hr,  
  $cgi->end_form;  
   
  return $html;  
243  }  }
244    
245  sub show_initial {      # build term deletions stuff
  my ($fig,$cgi,$html,$peg)=@_;  
  # generate a blank page  
246    
247   my $delete_col_hdrs = ["Delete","Source","ID: Term"];   my $delete_col_hdrs = ["Delete","Source","ID: Term"];
248   my @results = $fig->get_attributes($peg);   my @results = $fig->get_attributes($peg);
# Line 283  Line 263 
263       push(@$delete_table_rows,$row);       push(@$delete_table_rows,$row);
264       $counter = $counter + 1;       $counter = $counter + 1;
265   }   }
266    
267    
268        # build the page
269    
270   my $link = "protein.cgi?prot=$peg";   my $link = "protein.cgi?prot=$peg";
271   push @$html,   push @$html,
272   $cgi->start_multipart_form(),      #$cgi->start_multipart_form(),
273        $cgi->start_form(),
274        $cgi->hidden(-name=>'prot', -value=>'$peg'),
275        $cgi->hidden(-name=>'user', -value=>'$user'),
276   $cgi->br,   $cgi->br,
277   "<a href=$link>Back to protein page</a>",   "<a href=$link>Back to protein page</a>",
278   $cgi->br,   $cgi->br,
279   "<h2>Controlled Vocabulary Workbench</h2>\n",      "<h2>Controlled Vocabulary Workbench for $peg</h2>",
280   $cgi->hr,   $cgi->hr,
281   "<h4>Current Terms Assigned To Peg </h4>\n",      "<h4>Current Terms Assigned To $peg </h4>\n",
282   &HTML::make_table($delete_col_hdrs,$delete_table_rows),   &HTML::make_table($delete_col_hdrs,$delete_table_rows),
283   $cgi->br,   $cgi->br,
284   $cgi->submit(-name=>'request', -value=>'Delete Checked Terms'),   $cgi->submit(-name=>'request', -value=>'Delete Checked Terms'),
285        $cgi->end_form;
286    
287        push @$html,
288        $cgi->start_form(),
289        $cgi->hidden(-name=>'prot', -value=>'$peg'),
290        $cgi->hidden(-name=>'user', -value=>'$user'),
291   $cgi->hr,   $cgi->hr,
292   $cgi->br,   $cgi->br,
293   "<h4>Search for New Terms to Add </h4>\n",   "<h4>Search for New Terms to Add </h4>\n",
# Line 303  Line 296 
296    </select> &nbsp;&nbsp",    </select> &nbsp;&nbsp",
297   $cgi->textfield(-name => 'search_term', -size => 20),   $cgi->textfield(-name => 'search_term', -size => 20),
298   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),
  $cgi->hr,  
299   $cgi->br,   $cgi->br,
300   "<h4>Add Custom Terms </h4>\n",      $cgi->br,
301   "<h5>Source </h5>\n",      &HTML::make_table($add_col_hdrs,$add_table_rows),
302   $cgi->textfield(-name => 'custom_source', -size => 20),      $cgi->br,
303   "<h5>ID</h5>\n",      $add_terms_button,
304   $cgi->textfield(-name => 'custom_id', -size => 20),      $cgi->end_form;
305   "<h5>Term</h5>\n",  
306   $cgi->textfield(-name => 'custom_term', -size => 20),      push @$html,
307        $cgi->start_form(),
308        $cgi->hidden(-name=>'prot', -value=>'$peg'),
309        $cgi->hidden(-name=>'user', -value=>'$user'),
310        $cgi->hr,
311        "<h4>Add Custom Terms (WARNING: This is strongly discouraged to avoid data entry errors.)</h5>",
312        "<h3>$custom_term_error</h3>",
313        "<h5>Vocabulary Name (single word, no spaces or punctuation), e.g., MyVocab </h5>\n",
314        $cgi->textfield(-name => 'custom_source', -size => 48, -default=>'', -override=>1 ),
315        "<h5>Term ID (single word, no spaces or punctuation), e.g., A147</h5>\n",
316        $cgi->textfield(-name => 'custom_id', -size => 32, -default=>'', -override=>1),
317        "<h5>Term text, e.g., catalytic activity</h5>\n",
318        $cgi->textfield(-name => 'custom_term', -size => 70, -default=>'', -override=>1 ),
319   $cgi->br,$cgi->br,   $cgi->br,$cgi->br,
320   $cgi->submit(-name=>'request', -value=>'Add Custom Term'),   $cgi->submit(-name=>'request', -value=>'Add Custom Term'),
321   $cgi->br,   $cgi->br,

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3