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

View of /FigWebServices/check_anno.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Thu Jan 26 03:36:47 2006 UTC (13 years, 10 months ago) by overbeek
Branch: MAIN
add check_anno.cgi

# -*- perl -*-
#
# Copyright (c) 2003-2006 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 URI::Escape;  # uri_escape
use HTML;
use Data::Dumper;
use strict;
use CGI;
my $cgi = new CGI;

if (0) {
    my $VAR1;
    eval(join("",`cat /tmp/check_anno_parms`));
    $cgi = $VAR1;
#   print STDERR &Dumper($cgi);
}

if (0) {
    print $cgi->header;
    my @params = $cgi->param;
    print "<pre>\n";
    foreach $_ (@params) {
		print "$_\t:",join(",",$cgi->param($_)),":\n";
    }

    if (0) {
        if (open(TMP,">/tmp/check_anno_parms")) {
	    	print TMP &Dumper($cgi);
	    	close(TMP);
		}
    }
    exit;
}

my $html = [];
unshift @$html, "<TITLE>The SEED Annotation Checking Page</TITLE>\n";

my $file = $cgi->param('file');
if ((! $file) || (! -s $file))
{
    push(@$html,"<h1>Sorry, the file = $file is not there</h1>\n");
    &HTML::show_page($cgi,$html);
    exit;
}

my $user = $cgi->param('user');
if (! $user) 
{
    push(@$html,"<h1>Sorry, you need to specify a user</h1>\n");
    &HTML::show_page($cgi,$html);
    exit;
}

my @tab = sort { ($a->[0] cmp $b->[0]) or ($a->[1] cmp $b->[1]) or ($a->[2] cmp $b->[2]) }
          map { chop; [split(/\t/,$_)] }
          `cat $file`;

my $start_at = $cgi->param('start_at');
$start_at = $start_at ? $start_at : 0;

my @actions = grep { $_ =~ /^action/ } $cgi->param;

if ((@actions > 0) && open(TMP,">> $FIG_Config::global/annotation_checks"))
{
    foreach my $action (@actions)
    {
	if (($action =~ /^action(\d+)/) && (my $i = $1) && (my $do = $cgi->param($action)))
	{
	    my $f1 = $tab[$i]->[0];
	    my $f2 = $tab[$i]->[1];
	    my $peg1 = $tab[$i]->[2];

	    my @set = ();
	    while (($i < @tab) && ($tab[$i]->[0] eq $f1) && ($tab[$i]->[1] eq $f2) && ($tab[$i]->[2] eq $peg1))
	    {
		push(@set,$tab[$i]);
		$i++;
	    }
	    print TMP "$do\n";
	    foreach $_ (@set)
	    {
		print TMP join("\t",@$_),"\n";
	    }
	    print TMP "//\n";
	}
    }
    close(TMP);
}
	
my $col_hdrs = ["NI","=","I","FIG Function","Other Function","FIG IDs","Other IDs"];
my $tab = [];
push(@$html,$cgi->start_form( -method => 'post',
				  -action => 'check_anno.cgi'));
push(@$html, $cgi->hidden(-name => 'user', -value => $user));
push(@$html, $cgi->hidden(-name => 'file', -value => $file));

my $got = 0;
my $i = $start_at; 
while (($i < @tab) && ($got < 25))
{
    my $f1 = $tab[$i]->[0];
    my $f2 = $tab[$i]->[1];
    my $peg1 = $tab[$i]->[2];

    my @set = ();
    while (($i < @tab) && ($tab[$i]->[0] eq $f1) && ($tab[$i]->[1] eq $f2) && ($tab[$i]->[2] eq $peg1))
    {
	push(@set,$tab[$i]);
	$i++;
    }
    my @fig = map { $_->[2] } @set;
    my %fig = map { $_ => 1 } @fig;
    @fig = sort { &FIG::by_fig_id($a,$b) } keys(%fig);

    my @other = map { $_->[3] } @set;
    my %other = map { $_ => 1 } @other;
    @other = sort keys(%other);

    my @figL    = map { &HTML::fid_link($cgi,$_) } @fig;
    my @otherL  = map { &HTML::set_prot_links($cgi,$_) } @other;

    my @actions = $cgi->radio_group( -name => "action$start_at",
				     -nolabels => 1,
				     -override => 1,
				     -values => ["NI","=","I"]);
    push(@$tab,[@actions,$f1,$f2,join("<br>",@figL),join("<br>",@otherL)]);
    $got++;
    $start_at = $i;
}
if (@$tab > 0)
{
    push(@$html, $cgi->hidden(-name => 'start_at', -value => $start_at));
    push(@$html,&HTML::make_table($col_hdrs,$tab,"Discrepancies in Annotations"));
    push(@$html,$cgi->submit('take_actions'), $cgi->end_form);
    &HTML::show_page($cgi,$html);
}
else
{
    $html = [];
    push(@$html,"<h1>Nothing left to do</h1>\n");
    &HTML::show_page($cgi,$html);
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3