[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.1, Wed Oct 19 14:39:06 2005 UTC revision 1.2, Wed Oct 19 20:20:07 2005 UTC
# Line 20  Line 20 
20    
21  #for testing  #for testing
22    
23  my $peg = "fig|9598.2.peg.1";  my $peg = $cgi->param('prot');
24    #my $peg = "fig|9598.2.peg.1";
25    
26  my $fig;  my $fig;
27  eval {  eval {
# Line 88  Line 89 
89      if ($cgi->param('select_cv')) {$cv=$cgi->param('select_cv')}      if ($cgi->param('select_cv')) {$cv=$cgi->param('select_cv')}
90      &search($fig,$cgi,$html,$peg,$cv,$search_term);      &search($fig,$cgi,$html,$peg,$cv,$search_term);
91  }  }
92    elsif ($cgi->param('request') eq "Add New Terms")
93    {
94        my %id_term_to_source;
95        my @checked;
96        my @param_list = $cgi->param();
97        if (@param_list)
98        {
99            foreach my $p (@param_list)
100            {
101              if ( $p=~/add_checked/)
102              {
103                  print STDERR "checked_param:$p\n";
104                 if($cgi->param($p))
105                 {
106                     $value = $cgi->param($p);
107                     push(@checked,$value)
108                 }
109              }
110            }
111    
112            for my $c (@checked)
113            {
114               @temp = split("split_here",$c);
115               $source = $temp[0];
116               $id_term = $temp[1];
117               $id_term_to_source{$id_term} =$source ;
118               print STDERR "checked_source:$source\n";
119               print STDERR "checked_value:$c\n";
120            }
121        }
122        &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
123    
124    }
125    
126  elsif ($cgi->param('request') eq "Add Custom Term")  elsif ($cgi->param('request') eq "Add Custom Term")
127  {  {
128        my %id_term_to_source;
129        my $id_term;
130      if ($cgi->param('custom_source')) {$custom_source=$cgi->param('custom_source')}      if ($cgi->param('custom_source')) {$custom_source=$cgi->param('custom_source')}
131      if ($cgi->param('custom_id')) {$custom_id=$cgi->param('custom_id')}      if ($cgi->param('custom_id')) {$custom_id=$cgi->param('custom_id')}
132      if ($cgi->param('custom_term')) {$custom_term=$cgi->param('custom_term')}      if ($cgi->param('custom_term')) {$custom_term=$cgi->param('custom_term')}
133        $id_term = $custom_id.": ".$custom_term;
134      my $triple = [$custom_source,$custom_id,$custom_term];      $id_term_to_source{$id_term} = $custom_source;
135      &add_custom_term($fig,$cgi,$html,$peg,$triple);      &add_terms($fig,$cgi,$html,$peg,\%id_term_to_source);
136  }  }
137    
138  else  else
# Line 117  Line 154 
154  sub search  sub search
155  {  {
156      my ($fig,$cgi,$html,$peg,$cv,$search_term) =@_;      my ($fig,$cgi,$html,$peg,$cv,$search_term) =@_;
157      open(LOOKUP,"$FIG_config::global/$cv_lookup.txt");      $file = $FIG_Config::global."/".$cv."_lookup.txt";
158        open(LOOKUP,"$file");
159      my @lines = <LOOKUP>;      my @lines = <LOOKUP>;
160      my $search_results = grep(/$search_term/i,@lines);      my @grep_results = grep(/$search_term/i,@lines);
161        print STDERR "$grep_results[0]\n";
162        my $search_results = [@grep_results];
163      &show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);      &show_search_results($fig,$cgi,$html,$peg,$cv,$search_results);
164  }  }
165    
166  sub add_custom_term  sub add_terms
167    {
168        my ($fig,$cgi,$html,$peg,$id_term_to_source) =@_ ;
169        my @id_term = keys(%{$id_term_to_source});
170        foreach my $it (@id_term)
171  {  {
172      my ($fig,$cgi,$html,$peg,$triple) =@_ ;          print STDERR "added_source:$id_term_to_source->{$it}\n";
173      my @input = @$triple;          print STDERR "added_value:$it\n";
174      my $key = $input[0];  
175      my $id = $input[1];          $fig->add_attribute($peg,$id_term_to_source->{$it},$it);
176      my $term = $input[2];  
177      $value = $id.": ".$term;      }
178      $fig->add_attribute($peg,$key,$value);      &show_initial($fig,$cgi,$html,$peg);
179  }  }
180    
181  sub show_search_results {  sub show_search_results {
# Line 139  Line 183 
183   @sr = @$search_results;   @sr = @$search_results;
184   my $add_col_hdrs = ["Add","Source","ID: Term"];   my $add_col_hdrs = ["Add","Source","ID: Term"];
185   my $add_table_rows;   my $add_table_rows;
186     my $counter = 0;
187   for my $r (@sr)   for my $r (@sr)
188   {   {
189       @temp = split("\t",$r);       @temp = split("\t",$r);
190       $row = [];       $row = [];
191       $source = $cv;       $source = $cv;
192       $id_and_term = $temp[1];       $id= $temp[1];
193       $cb ="<input type=checkbox name=add_checked value=$id_and_term>" ;       print STDERR "id:$id\n";
194         $term = $temp[2];
195         print STDERR "term:$term\n";
196         $id_and_term = $id.": ".$term;
197         $cb_value = $cv."split_here".$id.": ".$term;
198         print STDERR "iandt:$id_and_term\n";
199         $cb ="<input type=checkbox name=add_checked_$counter value='$cb_value'>" ;
200       push(@$row,$cb);       push(@$row,$cb);
201       push(@$row,$source);       push(@$row,$source);
202       push(@$row,$id_and_term);       push(@$row,$id_and_term);
203       push(@$add_table_rows,$row);       push(@$add_table_rows,$row);
204         $counter = $counter + 1;
205   }   }
206    
207   my $delete_col_hdrs = ["Delete","Source","ID: Term"];   my $delete_col_hdrs = ["Delete","Source","ID: Term"];
208   my @results = $fig->get_attributes($peg,'GO');   my @results = $fig->get_attributes($peg,'GO');
209   my $delete_table_rows;   my $delete_table_rows;
210   my $counter = 0;   $counter = 0;
211   for my $r (@results)   for my $r (@results)
212   {   {
213       $row = [];       $row = [];
214       $source = $r->[1];       $source = $r->[1];
215    
216       $id_and_term = $r->[2];       $id_and_term = $r->[2];
217       $cb ="<input type=checkbox name=delete_checked_$counter value=$id_and_term>" ;       $cb ="<input type=checkbox name=delete_checked_$counter value=$id_and_term>" ;
218       push(@$row,$cb);       push(@$row,$cb);
# Line 181  Line 234 
234   $cgi->br,   $cgi->br,
235   "<h4>Search for New Terms to Add </h4>\n",   "<h4>Search for New Terms to Add </h4>\n",
236   "<select name=select_cv>   "<select name=select_cv>
         <option value=all >all CVs</option>  
237          <option value=go  >Gene Ontology</option>          <option value=go  >Gene Ontology</option>
         <option value=omim >OMIM</option>  
238    </select> &nbsp;&nbsp",    </select> &nbsp;&nbsp",
239   $cgi->textfield(-name => "search_term", -size => 20),   $cgi->textfield(-name => "search_term", -size => 20),
240   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),
241   $cgi->br,   $cgi->br,
242   &HTML::make_table($add_col_hdrs,$add_table_rows),   &HTML::make_table($add_col_hdrs,$add_table_rows),
243     $cgi->br,
244     $cgi->submit(-name=>'request', -value=>'Add New Terms'),
245   $cgi->hr,   $cgi->hr,
246   $cgi->br,   $cgi->br,
247   "<h4>Add Custom Terms </h4>\n",   "<h4>Add Custom Terms </h4>\n",
# Line 211  Line 264 
264   my ($fig,$cgi,$html,$peg)=@_;   my ($fig,$cgi,$html,$peg)=@_;
265   # generate a blank page   # generate a blank page
266    
267   my $col_hdrs = ["Delete","Source","ID: Term"];   my $delete_col_hdrs = ["Delete","Source","ID: Term"];
268   my @results = $fig->get_attributes($peg,'GO');   my @results = $fig->get_attributes($peg);
269   my $table_rows;   print STDERR "@results\n";
270     print STDERR "peg:$peg\n";
271     my $delete_table_rows;
272     my $counter =0;
273   for my $r (@results)   for my $r (@results)
274   {   {
275       $row = [];       $row = [];
276       $source = $r->[1];       $source = $r->[1];
277         print STDERR "source:$source\n";
278       $id_and_term = $r->[2];       $id_and_term = $r->[2];
279       $cb ="<input type=checkbox name=delete_checked value=$source\t$id_and_term>" ;       $cb ="<input type=checkbox name=delete_checked_$counter value=$source\t$id_and_term>" ;
280       push(@$row,$cb);       push(@$row,$cb);
281       push(@$row,$source);       push(@$row,$source);
282       push(@$row,$id_and_term);       push(@$row,$id_and_term);
283       push(@$table_rows,$row);       push(@$delete_table_rows,$row);
284         $counter = $counter + 1;
285   }   }
286     my $link = "protein.cgi?prot=$peg";
287    push @$html,    push @$html,
288   $cgi->start_multipart_form(),   $cgi->start_multipart_form(),
289     $cgi->br,
290     "<a href=$link>Back to protein page</a>",
291     $cgi->br,
292   "<h2>Controlled Vocabulary Workbench</h2>\n",   "<h2>Controlled Vocabulary Workbench</h2>\n",
293   $cgi->hr,   $cgi->hr,
294   "<h4>Current Terms Assigned To Peg </h4>\n",   "<h4>Current Terms Assigned To Peg </h4>\n",
295   &HTML::make_table($col_hdrs,$table_rows),   &HTML::make_table($delete_col_hdrs,$delete_table_rows),
296   $cgi->br,   $cgi->br,
297   $cgi->submit(-name=>'request', -value=>'Delete Checked Terms'),   $cgi->submit(-name=>'request', -value=>'Delete Checked Terms'),
298   $cgi->hr,   $cgi->hr,
299   $cgi->br,   $cgi->br,
300   "<h4>Search for New Terms to Add </h4>\n",   "<h4>Search for New Terms to Add </h4>\n",
301   "<select name=select_cv>   "<select name=select_cv>
302          <option value=all >all CVs</option>          <option value=GO  >Gene Ontology</option>
         <option value=go  >Gene Ontology</option>  
         <option value=omim >OMIM</option>  
303    </select> &nbsp;&nbsp",    </select> &nbsp;&nbsp",
304   $cgi->textfield(-name => 'search_term', -size => 20),   $cgi->textfield(-name => 'search_term', -size => 20),
305   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),   $cgi->submit(-name=>'request', -value=>'Search Selected Controlled Vocabulary'),

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3