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

View of /FigWebServices/correspondence.cgi

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.2 - (download) (annotate)
Mon Dec 5 19:12:12 2005 UTC (14 years, 4 months ago) by olson
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.1: +17 -0 lines
add license words

# 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.

# _*_ perl _*_


=head1 Description

A cgi script to control the creation of correspondence tables. This will essentially deprecate pir.cgi and many of those functions will be moved here. The general idea is to provide buttons to allow the downloading and generation of correspondence tables for several sites, including PIR, swiss-prot, kegg, and others.


use strict;
use FIG;
use HTML;
use raelib;
my $raelib=new raelib;
use CGI;
my $cgi=new CGI;
use LWP::Simple qw(!head); # see the caveat in perldoc LWP about importing two head methods.

my $fig;
eval {
    $fig = new FIG;

if ($@ ne "")
    my $err = $@;    
    push(@html, $cgi->p("Error connecting to SEED database."));
    if ($err =~ /Could not connect to DBI:.*could not connect to server/)
        push(@html, $cgi->p("Could not connect to relational database of type $FIG_Config::dbms named $FIG_Config::db on port $FIG_Config::dbport."));
        push(@html, $cgi->pre($err));
    &HTML::show_page($cgi, \@html, 1);

$ENV{"PATH"} = "$FIG_Config::bin:$FIG_Config::ext_bin:" . $ENV{"PATH"};

# these should probably be in FIG::Config. Oh well.
# for each off site that we want, we need three pieces of information:
# remote location (ftp or http site)
# file name to store the file as locally (usually the .dat file)
# file name for the correspondence file to create

# note that the fileinfo hash is a hash of hashes. 

my %fileinfo=(
  'PIR' => 
 	remote		=> "ftp://ftp.pir.georgetown.edu/pir_databases/pirsf/data/pirsfinfo.dat",
	localfile	=> "pirsfinfo.dat",
	correspondence	=> "pirsfcorrespondence.txt"
  'UniProt' => 
 	remote		=> "http://pir2.georgetown.edu/~suzek/for_SEED/uniprot_info.gz",
	localfile	=> "uniprot_info.gz",
	correspondence	=> "uniprotcorrespondence.txt"
  'Prosite' => 
 	remote		=> "ftp://ca.expasy.org/databases/prosite/release_with_updates/prosite.dat",
	localfile	=> "prosite.dat",
	correspondence	=> "prositecorrespondence.txt"

# directory to put all the files in
my $filedir = "$FIG_Config::data/Global/correspondence/";
# this should really only be done the first time we run this script
unless (-e $filedir) {mkdir $filedir,0755}

my $html = [];
my $user = $cgi->param('user');

unshift @$html, "<TITLE>The SEED - PIR comparison page</TITLE>\n";
# always put this table up so we know what we have

if ($cgi->param('generate_correspondence')) {
 foreach my $db (keys %fileinfo) {
  &generate_correspondence($db, $html, $cgi) if ($cgi->param($db) || $cgi->param("download$db"));


sub show_table {
 my ($fig,$cgi,$html)=@_;
 # generate a blank page

 # Get file modification data. 
 # Note we will only go out and get the remote data if we have been asked for it. We don't want to do this without being asked because it may take a while
 # especially if we are not online!
 # we are going to have the following columns:
 # Correspondence Name		Remote file mod time		Local copy of remote file mod time		Local copy of correspondence file mod time

 # get the file information and put it in a table
 my $tab=[];
 foreach my $db (keys %fileinfo) {
  my @row=($cgi->checkbox(-name=>$db, -label=>''), $cgi->checkbox(-name=>"download$db", -label=>''), $db, "Not checked yet");
  if ($cgi->param("get_remote_time")) {
   my ($content_type, $document_length, $remotemtime, $expires, $server)=LWP::Simple::head($fileinfo{$db}->{'remote'});
  foreach my $f ($fileinfo{$db}->{'localfile'}, $fileinfo{$db}->{'correspondence'}) {
   my $localmtime="Not created yet";
   # if we don't have the file yet, we don't want to panic!
   if (-e "$filedir/$f") {
    my @stat=stat("$filedir/$f");
   push @row, $localmtime;
  push @$tab, \@row;

 push (@$html, $cgi->start_form(-action => "correspondence.cgi"),
  $cgi->h2("Correspondence Tables Between Local and Remote Files."), 
  &HTML::make_table(["Correspondence", "Download", "Database", "Remote File", "Local Copy of Remote File", "Correspondence File"], $tab, "File Modification Times"),
  $cgi->submit('get_remote_time', 'Check Times for Remote Files'), $cgi->submit('generate_correspondence', 'Download or Generate Correspondence'), $cgi->reset(),

sub generate_correspondence {
 my ($db, $html, $cgi)=@_;
 my $bkj=$fig->run_in_background(sub
        my $time=time;
        print "Generating correspondence table with $db began at ", scalar(localtime($time)), "\n";
        # download the file if we need to
	if (!-e $fileinfo{$db}->{'localfile'} || $cgi->param("download$db")) {
	 my $gotit=LWP::Simple::getstore($fileinfo{$db}->{remote}, $fileinfo{$db}->{localfile});
	 unless ($gotit) {
	  print "WARNING: There was an error downloading the data from ", $fileinfo{$db}->{remote}, " to ", $fileinfo{$db}->{localfile}, "\n";
        if ($cgi->param($db)) {
	 # generate the correspondences
         # the actual generate of the correspondences is handed off to raelib
         my $lines=0;
         if ($db eq "Prosite") {$lines=$raelib->prositecorrespondence($filedir."/".$fileinfo{$db}->{localfile}, $filedir."/".$fileinfo{$db}->{correspondence})}
         elsif ($db eq "UniProt") {$lines=$raelib->uniprotcorrespondence($filedir."/".$fileinfo{$db}->{localfile}, $filedir."/".$fileinfo{$db}->{correspondence})}
         elsif ($db eq "PIR") {$lines=$raelib->pircorrespondence($filedir."/".$fileinfo{$db}->{localfile}, $filedir."/".$fileinfo{$db}->{correspondence})}
 	 print "Generated $lines lines of correspondence for $db\n" if ($lines);
        print "Complete at ", scalar(localtime(time)), ". Running took ", (time-$time)/60, " minutes\n";

 push @$html, "<h2>Creating your data has started</h2>",
    "<p>The job has started in the background but will likely take some time.<br />\n",
    "The job has an ID of $bkj, and you can check it out from the <A href=\"/FIG/seed_ctl.cgi\">SEED Control Panel</a></p>\n";
 return $html;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3