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

View of /FigWebServices/get_dlit.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (annotate)
Sun May 25 16:29:08 2008 UTC (12 years ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2008_06_18, rast_rel_2008_06_16
Changes since 1.3: +13 -7 lines
fixes to get_dlits.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 HTML;
use strict;

use CGI;
my $cgi = new CGI;


if (0)
{
    my $VAR1;
    eval(join("",`cat /tmp/get_dlit_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/get_dlit_parms"))
	{
	    print TMP &Dumper($cgi);
	    close(TMP);
	}
    }
    exit;
}
my($genome);

my $html = [];
unshift @$html, "<TITLE>Get Dlits</TITLE>\n";

my $user = $cgi->param('user'); 
my $curator = $cgi->param('curator');
my $roleN   = $cgi->param('roleN');
if ($roleN) { $roleN =~ s/^(\d+)\t.*$/$1/; }
my @checked = $cgi->param('checked');

if (! $user)
{
    push(@$html,$cgi->h1('you need to set user= in the URL'));
}
elsif (! -d "$FIG_Config::data/DlitByCurator")
{
    push(@$html,$cgi->h1("dlit data not installed"));
}
elsif (! $curator)
{
    if (opendir(CUR,"$FIG_Config::data/DlitByCurator/ByCurator"))
    {
	my @cur = sort grep { $_ !~ /^\./ } readdir(CUR);
	my $curN = @cur;
	push(@$html, $cgi->start_form(-action => "get_dlit.cgi", -method => 'post'),
	             $cgi->hidden(-name => 'user', -value=>$user),
	             "Pick one<br>",
	              $cgi->scrolling_list( -name   => 'curator',
				            -values => [ @cur ],
				            -size   => $curN
					    ),
	         $cgi->br,
	         $cgi->submit( 'Pick One' ),
	         $cgi->end_form
	 );
    }
	
}
elsif (! $roleN)
{
    if (opendir(CUR,"$FIG_Config::data/DlitByCurator/ByCurator/$curator"))
    {
	my @roles    = sort grep { $_ !~ /^\./ } readdir(CUR);
	my %rolesH = map { $_ => 1 } @roles;
	my @rolesE = map { $_ =~ /^(\d+)\t(\S.*\S)/; $rolesH{$1} ? [$1,$2] : () } 
                     `cat $FIG_Config::data/DlitByCurator/index.of.roles`;
	my @rolesV = map { $_->[0] } @rolesE;
	my %role_map = map { $_->[0] => $_->[1] } @rolesE;

	push(@$html, $cgi->start_form(-action => "get_dlit.cgi", -method => 'post', -target => '_blank'),
	             $cgi->hidden(-name => 'user', -value=>$user),
	             $cgi->hidden(-name => 'curator', -value=>$curator),
	             "Pick one<br>",
	              $cgi->scrolling_list( -name   => 'roleN',
				            -values => [ sort @rolesV ],
					    -labels => \%role_map,
				            -size   => 20
					    ),
	         $cgi->br,
	         $cgi->submit( 'Pick One' ),
	         $cgi->end_form
	 );
    }
	
}
elsif (@checked == 0)
{
    my $col_hdrs = ['Use','role','PubMed','Peg','Species','SP-ID','Swiss Prot Function','Paper'];
    my $tab = [];
    foreach $_ (`cat $FIG_Config::data/DlitByCurator/ByCurator/$curator/$roleN`)
    {
	chop;
	my($cur,$role,$pubmed,$ids,$sp_func,$paper) = split(/\t/,$_);
	my @ids = split(/,/,$ids);
	foreach my $tuple (@ids)
	{
	    my($peg,$sp,$gs) = split(/:/,$tuple);
	    my $check = $cgi->checkbox(-name => 'checked', -value => "$peg:$pubmed", -checked => 0, -override => 1, -label => '');
	    push(@$tab,[$check,
			$role,
			"<a target=_blank href=http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=search&term=$pubmed>$pubmed</a>",
			&HTML::fid_link($cgi,$peg),
			$gs,
			&HTML::sp_link($cgi,"sp|$sp"),
			$sp_func,
			$paper
			]);
	}
    }
    push(@$html, $cgi->start_form(-action => "get_dlit.cgi", -method => 'post'),
	         $cgi->hidden(-name => 'user', -value=>$user),
	         $cgi->hidden(-name => 'curator', -value=>$curator),
	         $cgi->hidden(-name => 'roleN', -value=>$roleN),
                 &HTML::make_table($col_hdrs,$tab,'Possible Papers'),
	         $cgi->br,
	         $cgi->submit( 'Save Dlits' ),
	         $cgi->end_form
	 );


}
elsif (@checked > 0)
{
    if (open(DLITS,">>$FIG_Config::data/DlitByCurator/dlits"))
    {
	foreach $_ (@checked)
	{
	    $_ =~ s/:/\t/;
	    print DLITS "$_\t$user\n";
	}
	close(DLITS);
    }
    &FIG::verify_dir("$FIG_Config::data/DlitByCurator/Saved/$curator");
    system("mv $FIG_Config::data/DlitByCurator/ByCurator/$curator/$roleN $FIG_Config::data/DlitByCurator/Saved/$curator/$roleN");
    push(@$html,$cgi->h1("$roleN processed"));
}

&HTML::show_page($cgi,$html);


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3