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

View of /FigWebServices/edit_feature.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Sat Aug 23 23:39:22 2008 UTC (11 years, 2 months ago) by golsen
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2008_09_30, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, rast_rel_2008_10_09, mgrast_dev_04012011, rast_release_2008_09_29, mgrast_rel_2008_0923, mgrast_rel_2008_0919, rast_rel_2009_07_09, rast_rel_2010_0827, mgrast_rel_2008_1110, myrast_33, rast_rel_2011_0928, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, HEAD
Changes since 1.1: +2 -2 lines
Move writing of assignment annotation from a case-by-case basis (and it
was missing in several key places) to the FIG::assign_function.

Modify the code in each of the calling locations to not make duplicate
annotations.

At the same time, remove (most) of the instances of making different
calls to assign_function depending on the user name.  assign_function
treats everyone as master (but writes an annotation with the real user
name).

# Copyright (c) 2003-2008 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
#
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License.
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

use FIG;
my $fig = new FIG;

use HTML;
use strict;
use GenoGraphics;
use CGI;
my $cgi = new CGI;
use FIG_CGI;

my ($fig, $cgi, $user) = FIG_CGI::init(debug_save   => 0,
				       debug_load   => 0,
				       print_params => 0
				      );

my $html = [];

if (! $user)
{
    unshift @$html, "<TITLE>The SEED: Edit Feature Page</TITLE>\n";
    push(@$html,"<h1>Sorry, you need to specify a user</h1>\n");
    &HTML::show_page($cgi,$html);
    exit;
}

unshift @$html, "<TITLE>The SEED Edit Feature Page</TITLE>\n";

my $feature = $cgi->param('feature');
if ((! $feature) || (! $fig->is_real_feature($feature)))
{
    unshift @$html, "<TITLE>The SEED: Edit Feature Page</TITLE>\n";
    push(@$html,"<h1>Sorry, you need to specify a feature</h1>\n");
    &HTML::show_page($cgi,$html);
    exit;
}

my $request = $cgi->param("request") ||
              $cgi->param('Delete Feature') ||
              $cgi->param('Replace Feature') ||
              $cgi->param('Update Data') ||
	      "";


if ($request eq 'Update Data')
{
    &update($fig,$cgi,$html,$user,$feature);
}
elsif ($request eq 'Delete Feature')
{
    &delete($fig,$cgi,$html,$user,$feature);
}
elsif ($request eq 'Replace Feature')
{
    &replace($fig,$cgi,$html,$user,$feature);
}
else
{
    &format_feature_data($fig,$cgi,$html,$user,$feature);
}
&HTML::show_page($cgi,$html);
exit;

sub update {
    my($fig,$cgi,$html,$user,$fid) = @_;

    my $loc = $fig->feature_location($fid);
    my $aliases = $fig->feature_aliases($fid);
    my $function = $fig->function_of($fid);
    my($translation,$new_translation);
    if (&FIG::ftype($fid) eq 'peg')
    {
	$new_translation = $cgi->param('translation');
    }

    my $new_func = $cgi->param('function');
    my $new_loc  = $cgi->param('location');
    my $new_aliases = $cgi->param('aliases');


    if ($loc ne $new_loc)
    {
	$fig->change_location_of_feature($fid,$new_loc,$new_translation);
	push(@$html,$cgi->h2("changed location of $fid to $new_loc"));
    }

    if ($aliases ne $new_aliases)
    {
	&FIG::add_tbl_entry($fid,$new_loc,$aliases);
	push(@$html,$cgi->h2("changed aliases of $fid to $new_aliases"));
    }

    if ($function ne $new_func)
    {
	$fig->assign_function($fid,$user,$new_func);
	# $fig->add_annotation($fid,$user,"Set master function to\n$new_func\n");
	push(@$html,$cgi->h2("changed function of $fid to $new_func"));
    }
    &format_feature_data($fig,$cgi,$html,$user,$fid);
}

sub replace {
    my($fig,$cgi,$html,$user,$fid) = @_;

    my $new_func = $cgi->param('function');
    my $new_loc  = $cgi->param('location');
    my $aliases = $fig->feature_aliases($fid);
    my $new_aliases = $cgi->param('aliases');
    my $new_translation = $cgi->param('translation');

    my $new_fid = $fig->replace_features_with( old_fids => $fid,
					       user     => $user,
					       genome   => &FIG::genome_of($fid),
					       type     => &FIG::ftype($fid),
					       location => $new_loc,
					       translation => $new_translation,
					       function => $new_func
					       );
    if ($aliases ne $new_aliases)
    {
	&FIG::add_tbl_entry($fid,$new_loc,$aliases);
    }
    my $fid_link = &HTML::fid_link($cgi,$fid);
    push(@$html,$cgi->h1("Replaced $fid_link with $new_fid"));
}

sub delete {
    my($fig,$cgi,$html,$user,$feature) = @_;
    $fig->delete_feature($feature);
    push(@$html,$cgi->h1("$feature deleted"));
}

sub format_feature_data {
    my($fig,$cgi,$html,$user,$fid) = @_;

    my $loc = $fig->feature_location($fid);
    my $aliases = $fig->feature_aliases($fid);
    my $function = $fig->function_of($fid);

    push(@$html,$cgi->start_form(-action => "edit_feature.cgi"),
	        $cgi->hidden(-name => 'user', -value => $user, -override => 1),
	        $cgi->hidden(-name => 'feature', -value => $fid, -override => 1),
	        $cgi->h1("Edit Data Relating to $fid"),
	        "Location: ",$cgi->textfield(-name => "location", -size => 100, -value => $loc),$cgi->br,
                "Aliases: &nbsp;&nbsp;",$cgi->textfield(-name => "aliases", -size => 100, -value => $aliases),$cgi->br,
                "Function: ",$cgi->textfield(-name => "function", -size => 100, -value => $function),$cgi->br,
	        $cgi->br,
	 );
    if (&FIG::ftype($fid) eq "peg")
    {
	my $translation = $fig->get_translation($fid);
	my $text = <<'END_TEXT';
<br><br>
Since you are editing a PEG, you need to understand the implications of editing the location. <br>
If you edit the location and just update the feature, the result will be a PEG for which the similarity data <br>
does not precisely match the actual characters in the translation (assuming that altering the location <br>
resulted in an alteration of the translation, as well).  We will periodically search for such mismatches <br>
and rerun similarities for the effected PEGs.
<p>
You have the option of replacing the PEG, which assigns a new ID (inheriting annotations from the old). <br>
In this case, you will have no similarities for a period (hopefully, short) and then they should appear. <br>
<br><br>
END_TEXT
        push(@$html,"Translation: ",$cgi->textfield(-name => "translation", -size => 100, -value => $translation),$cgi->br,
	            $text,
	            $cgi->submit('Replace Feature')
	     );
    }
    push(@$html,$cgi->submit('Update Data'),$cgi->submit('Delete Feature'),
                $cgi->end_form
	 );
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3