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

Annotation of /FigWebServices/edit_feature.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : golsen 1.2 # Copyright (c) 2003-2008 University of Chicago and Fellowship
2 : overbeek 1.1 # for Interpretations of Genomes. All Rights Reserved.
3 :     #
4 :     # This file is part of the SEED Toolkit.
5 :     #
6 :     # The SEED Toolkit is free software. You can redistribute
7 :     # it and/or modify it under the terms of the SEED Toolkit
8 :     # Public License.
9 :     #
10 :     # You should have received a copy of the SEED Toolkit Public License
11 :     # along with this program; if not write to the University of Chicago
12 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
13 :     # Genomes at veronika@thefig.info or download a copy from
14 :     # http://www.theseed.org/LICENSE.TXT.
15 :     #
16 :    
17 :     use FIG;
18 :     my $fig = new FIG;
19 :    
20 :     use HTML;
21 :     use strict;
22 :     use GenoGraphics;
23 :     use CGI;
24 :     my $cgi = new CGI;
25 :     use FIG_CGI;
26 :    
27 :     my ($fig, $cgi, $user) = FIG_CGI::init(debug_save => 0,
28 :     debug_load => 0,
29 :     print_params => 0
30 :     );
31 :    
32 :     my $html = [];
33 :    
34 :     if (! $user)
35 :     {
36 :     unshift @$html, "<TITLE>The SEED: Edit Feature Page</TITLE>\n";
37 :     push(@$html,"<h1>Sorry, you need to specify a user</h1>\n");
38 :     &HTML::show_page($cgi,$html);
39 :     exit;
40 :     }
41 :    
42 :     unshift @$html, "<TITLE>The SEED Edit Feature Page</TITLE>\n";
43 :    
44 :     my $feature = $cgi->param('feature');
45 :     if ((! $feature) || (! $fig->is_real_feature($feature)))
46 :     {
47 :     unshift @$html, "<TITLE>The SEED: Edit Feature Page</TITLE>\n";
48 :     push(@$html,"<h1>Sorry, you need to specify a feature</h1>\n");
49 :     &HTML::show_page($cgi,$html);
50 :     exit;
51 :     }
52 :    
53 :     my $request = $cgi->param("request") ||
54 :     $cgi->param('Delete Feature') ||
55 :     $cgi->param('Replace Feature') ||
56 :     $cgi->param('Update Data') ||
57 :     "";
58 :    
59 :    
60 :     if ($request eq 'Update Data')
61 :     {
62 :     &update($fig,$cgi,$html,$user,$feature);
63 :     }
64 :     elsif ($request eq 'Delete Feature')
65 :     {
66 :     &delete($fig,$cgi,$html,$user,$feature);
67 :     }
68 :     elsif ($request eq 'Replace Feature')
69 :     {
70 :     &replace($fig,$cgi,$html,$user,$feature);
71 :     }
72 :     else
73 :     {
74 :     &format_feature_data($fig,$cgi,$html,$user,$feature);
75 :     }
76 :     &HTML::show_page($cgi,$html);
77 :     exit;
78 :    
79 :     sub update {
80 :     my($fig,$cgi,$html,$user,$fid) = @_;
81 :    
82 :     my $loc = $fig->feature_location($fid);
83 :     my $aliases = $fig->feature_aliases($fid);
84 :     my $function = $fig->function_of($fid);
85 :     my($translation,$new_translation);
86 :     if (&FIG::ftype($fid) eq 'peg')
87 :     {
88 :     $new_translation = $cgi->param('translation');
89 :     }
90 :    
91 :     my $new_func = $cgi->param('function');
92 :     my $new_loc = $cgi->param('location');
93 :     my $new_aliases = $cgi->param('aliases');
94 :    
95 :    
96 :     if ($loc ne $new_loc)
97 :     {
98 :     $fig->change_location_of_feature($fid,$new_loc,$new_translation);
99 :     push(@$html,$cgi->h2("changed location of $fid to $new_loc"));
100 :     }
101 :    
102 :     if ($aliases ne $new_aliases)
103 :     {
104 :     &FIG::add_tbl_entry($fid,$new_loc,$aliases);
105 :     push(@$html,$cgi->h2("changed aliases of $fid to $new_aliases"));
106 :     }
107 :    
108 :     if ($function ne $new_func)
109 :     {
110 :     $fig->assign_function($fid,$user,$new_func);
111 : golsen 1.2 # $fig->add_annotation($fid,$user,"Set master function to\n$new_func\n");
112 : overbeek 1.1 push(@$html,$cgi->h2("changed function of $fid to $new_func"));
113 :     }
114 :     &format_feature_data($fig,$cgi,$html,$user,$fid);
115 :     }
116 :    
117 :     sub replace {
118 :     my($fig,$cgi,$html,$user,$fid) = @_;
119 :    
120 :     my $new_func = $cgi->param('function');
121 :     my $new_loc = $cgi->param('location');
122 :     my $aliases = $fig->feature_aliases($fid);
123 :     my $new_aliases = $cgi->param('aliases');
124 :     my $new_translation = $cgi->param('translation');
125 :    
126 :     my $new_fid = $fig->replace_features_with( old_fids => $fid,
127 :     user => $user,
128 :     genome => &FIG::genome_of($fid),
129 :     type => &FIG::ftype($fid),
130 :     location => $new_loc,
131 :     translation => $new_translation,
132 :     function => $new_func
133 :     );
134 :     if ($aliases ne $new_aliases)
135 :     {
136 :     &FIG::add_tbl_entry($fid,$new_loc,$aliases);
137 :     }
138 :     my $fid_link = &HTML::fid_link($cgi,$fid);
139 :     push(@$html,$cgi->h1("Replaced $fid_link with $new_fid"));
140 :     }
141 :    
142 :     sub delete {
143 :     my($fig,$cgi,$html,$user,$feature) = @_;
144 :     $fig->delete_feature($feature);
145 :     push(@$html,$cgi->h1("$feature deleted"));
146 :     }
147 :    
148 :     sub format_feature_data {
149 :     my($fig,$cgi,$html,$user,$fid) = @_;
150 :    
151 :     my $loc = $fig->feature_location($fid);
152 :     my $aliases = $fig->feature_aliases($fid);
153 :     my $function = $fig->function_of($fid);
154 :    
155 :     push(@$html,$cgi->start_form(-action => "edit_feature.cgi"),
156 :     $cgi->hidden(-name => 'user', -value => $user, -override => 1),
157 :     $cgi->hidden(-name => 'feature', -value => $fid, -override => 1),
158 :     $cgi->h1("Edit Data Relating to $fid"),
159 :     "Location: ",$cgi->textfield(-name => "location", -size => 100, -value => $loc),$cgi->br,
160 :     "Aliases: &nbsp;&nbsp;",$cgi->textfield(-name => "aliases", -size => 100, -value => $aliases),$cgi->br,
161 :     "Function: ",$cgi->textfield(-name => "function", -size => 100, -value => $function),$cgi->br,
162 :     $cgi->br,
163 :     );
164 :     if (&FIG::ftype($fid) eq "peg")
165 :     {
166 :     my $translation = $fig->get_translation($fid);
167 :     my $text = <<'END_TEXT';
168 :     <br><br>
169 :     Since you are editing a PEG, you need to understand the implications of editing the location. <br>
170 :     If you edit the location and just update the feature, the result will be a PEG for which the similarity data <br>
171 :     does not precisely match the actual characters in the translation (assuming that altering the location <br>
172 :     resulted in an alteration of the translation, as well). We will periodically search for such mismatches <br>
173 :     and rerun similarities for the effected PEGs.
174 :     <p>
175 :     You have the option of replacing the PEG, which assigns a new ID (inheriting annotations from the old). <br>
176 :     In this case, you will have no similarities for a period (hopefully, short) and then they should appear. <br>
177 :     <br><br>
178 :     END_TEXT
179 :     push(@$html,"Translation: ",$cgi->textfield(-name => "translation", -size => 100, -value => $translation),$cgi->br,
180 :     $text,
181 :     $cgi->submit('Replace Feature')
182 :     );
183 :     }
184 :     push(@$html,$cgi->submit('Update Data'),$cgi->submit('Delete Feature'),
185 :     $cgi->end_form
186 :     );
187 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3