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

View of /FigWebServices/check_int_anno.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (annotate)
Fri Feb 3 18:42:27 2006 UTC (13 years, 9 months ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, rast_rel_2008_06_18, myrast_rel40, rast_rel_2008_06_16, mgrast_dev_05262011, rast_rel_2008_12_18, mgrast_dev_04082011, rast_rel_2008_07_21, rast_rel_2010_0928, rast_2008_0924, mgrast_version_3_2, mgrast_dev_12152011, rast_rel_2008_04_23, 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, caBIG-05Apr06-00, 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_0806, 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, caBIG-13Feb06-00, rast_rel_2009_03_26, mgrast_dev_10262011, rast_rel_2008_11_24, rast_rel_2008_08_07, HEAD
Changes since 1.2: +2 -6 lines
$/ fixes

# -*- 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;
use URI::Escape;  # uri_escape
use HTML;
use Data::Dumper;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my $fig = new FIG;


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

my $file = "$FIG_Config::global/annotation_checks";

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;
}

$/ = "\n//\n";


if ($cgi->param("show") eq "subsystem")
{
    $html=&showbyss($cgi,$html);
    &HTML::show_page($cgi,$html);
    exit;
}
        

my %probs;
foreach $_ (grep { $_ =~ /^I/ } `cat $file`)
{
    if ($_ =~ /^I\n(\S[^\t]+\S)\t(\S[^\t]+\S)\t(\S+)\t(\S+)/s)
    {
	$probs{"$3\t$4"} = [$1,$2,$3,$4];
    }
}

my @tab = sort { ($a->[0] cmp $b->[0]) or ($a->[1] cmp $b->[1]) or &FIG::by_fig_id($a->[2],$b->[2]) or ($a->[3] cmp $b->[3]) }
          map { $probs{$_} } 
          keys(%probs);

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

my $col_hdrs = ["","FIG Function","Other Function","FIG IDs","Other IDs"];
my $tab = [];
my $got = 0;
my $i = $start_at; 
while (($i < @tab) && ($got < $do))
{
    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))
    {
	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;

    push(@$tab,[$start_at,$f1,$f2,join("<br>",@figL),join("<br>",@otherL)]);
    $got++;
    $start_at = $i;
}

if (@$tab > 0)
{
    push(@$html,&HTML::make_table($col_hdrs,$tab,"Discrepancies in Annotations"));
    &HTML::show_page($cgi,$html);
}
else
{
    $html = [];
    push(@$html,"<h1>Nothing left to show</h1>\n");
    &HTML::show_page($cgi,$html);
}



sub showbyss {
    ($cgi, $html)=@_;
    local $/="\n//\n";
    my $time=time;
    my $limit=$cgi->param("limit");
    unless ($limit) {$limit=5}
    my $last=$cgi->param("last");
    unless (defined ($last)) {$last=0}
    
    unless (-e $FIG_Config::global."/annotation_checks") {die "The annotation checks file ". $FIG_Config::global."/annotation_checks is missing"}

    open(IN, $FIG_Config::global."/annotation_checks") || die "Can't open ".$FIG_Config::global."/annotation_checks";
    my $interesting; my $allss;
    while (<IN>)
    {   
        next unless (/^I/);
        my @a=split /\n/;
        my @pieces=split /\t/, $a[1];
        my @allsubsys;
        if ($allss->{$pieces[2]}) {@allsubsys=($allss->{$pieces[2]})}
        else {
            @allsubsys=$fig->subsystems_for_peg($pieces[2]);
            $allss->{$pieces[2]}=\@allsubsys;
        }
        foreach my $tple (@allsubsys)
        {   
            push @{$interesting->{$tple->[0]}}, \@pieces;
        }
    }
    close IN;


    $html=&directionlinks($html, $last, $limit);

    my $current=0;
    foreach my $subsys (keys %$interesting)
    {
        next unless ($fig->subsystem_curator($subsys) eq $cgi->param("user"));
        $current++;
        next if ($current <= $last);
        last if ($current > $last+$limit);
        my $tab=[];
        my $col_hdrs=["FIG Function", "Other Function", "FIG IDs", "Other IDs"];
        foreach my $row (@{$interesting->{$subsys}}) 
        {
            
            $row->[2]=&HTML::set_prot_links($cgi, $row->[2]) unless ($row->[2] =~ m/<a /);
            $row->[3]=&HTML::set_prot_links($cgi, $row->[3]) unless ($row->[3] =~ m/<a /);
            push @$tab, $row;
        }
        my %options=(width=>"100%");
        push @$html, 
           &HTML::make_table($col_hdrs,$tab,"Discrepancies in ".&HTML::sub_link($cgi, $subsys)." &nbsp; Curator: ".$fig->subsystem_curator($subsys), %options),
           $cgi->div({style=>"text-align: right"}, $cgi->p("<a href=\"#top\">Top</a>"));
    }

    $html=&directionlinks($html, $last, $limit);
    
    return $html;
}


sub directionlinks {
    my ($html, $last, $limit)=@_;
    if ($last >= $limit)
    {
        push (@$html, 
           $cgi->p("<a name=\"top\" />\n"),
           "<table border=0 width=100%><tr><td align=\"left\">",
           "<a href=\"check_int_anno.cgi?user=".$cgi->param("user")."&show=subsystem&last=".($last-$limit)."&limit=$limit\">Previous $limit Subsystems</a>",
           "</td><td align=\"right\">",
           "<a href=\"check_int_anno.cgi?user=".$cgi->param("user")."&show=subsystem&last=".($last+$limit)."&limit=$limit\">Next $limit Subsystems</a>",
           "</td></tr></table>\n");
    }
    else 
    {
        push (@$html, "<table border=0 width=100%><tr><td align=\"left\">Previous $limit Subsystems</td><td align=\"right\">",
           "<a href=\"check_int_anno.cgi?user=".$cgi->param("user")."&show=subsystem&last=".($last+$limit)."&limit=$limit\">Next $limit Subsystems</a>",
           "</td></tr></table>\n");
    }
    return $html;
}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3