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

View of /FigWebServices/protein.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.229 - (download) (annotate)
Mon Aug 14 16:12:08 2006 UTC (13 years, 7 months ago) by paczian
Branch: MAIN
Changes since 1.228: +66 -28 lines
updated to use new backend

# -*- 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 warnings;
use strict;

use CGI qw(:standard);
use HTML::Template;
use Data::Dumper;

use FIG;
use FIG_Config;
use FIG_CGI;
use UserData;
use FigWebServices::SeedComponents;
use PageBuilder;
use TemplateObject;

print header();

eval {
    &main();
};

if($@) {
    print start_html();
    print STDERR "EXCEPTION: $@\n";
    print "EXCEPTION: $@\n",end_html();
}

1;


sub main {
    # initialize fig object
    my ($fig, $cgi, $user) = FIG_CGI::init(debug_save   => 0,
                                           debug_load   => 0,
                                           print_params => 0);
    # check if an external page is to be displayed, called with data from seed.
    if ($cgi->param('tool')) {
        
        # Get the template object.
        my $to = TemplateObject->new($cgi, php => 'Tool');

        # Get the PEG.
        my $pegID = $cgi->param('prot');
        
        my $parameters = { fig_object  => $fig,
                           peg_id      => $pegID,
                           table_style => 'plain',
                           fig_disk    => $FIG_Config::fig_disk . "/",
                           form_target => 'protein.cgi'
        };

        # Format the header information.
        $to->titles($parameters);
        # Spit out an index link.
        $to->add(undef => "<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/><hr/>");

        # Call the tool.
        $to->add(results => & FigWebServices::SeedComponents::Basic::call_tool($fig, $pegID));
                 
        # Spit out another copy of the index link.
        $to->add(undef => "<hr/>" . FigWebServices::SeedComponents::Protein::get_index_link());

        # Output the page.
        print $to->finish();

    # check for the new framework
    } elsif ($cgi->param('new_framework')) {
        
        # display the new version
        my @out = `./frame.cgi`;
        print @out;
        exit;
        
    } else {
        
        # display the old version
        
        # Get the template object.
        my $to = TemplateObject->new($cgi, php => 'Protein', $cgi->param("request"));

        # Get the PEG.
        my $pegID = $cgi->param('prot');
	if ($pegID !~ /^fig\|/) {
	    my @poss = $fig->by_alias($pegID);
	    
	    if (@poss > 0) {
		$pegID = $poss[0];
	    }
	}
        
        my $parameters = { fig_object  => $fig,
                           peg_id      => $pegID,
                           table_style => 'plain',
                           fig_disk    => $FIG_Config::fig_disk . "/",
                           form_target => 'protein.cgi'
        };

        my ($min, $max, $features) = FigWebServices::SeedComponents::Protein::get_region_data($parameters);
        $parameters->{min} = $min;
        $parameters->{max} = $max;
        $parameters->{features} = $features;
        
        # Format the header information.
        $to->titles($parameters);
        # Spit out an index link.
        $to->add("<br/>" . FigWebServices::SeedComponents::Protein::get_index_link() . "<br/>") if $to->raw;
        $to->add(FigWebServices::SeedComponents::Framework::get_js_css_links()) if $to->raw;

        # check for request parameter
        my $request = $cgi->param("request") || "";

        # check for quick assign. Quick assigns do not work in Sprout, but if we're in Sprout and a
        # fast assign is requested, we've already crashed when we tried to create the template.
        if ($request eq "fast_assign")            {
            &FigWebServices::SeedComponents::Protein::make_assignment($fig,$cgi,$pegID);
            $request = "";
        }

        if    ($request eq "view_annotations") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::view_annotations($fig,$cgi,$pegID));
        } elsif ($request eq "view_all_annotations") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::view_all_annotations($fig,$cgi,$pegID));
        } elsif ($request eq "show_coupling_evidence") { 
            $to->add(results => &FigWebServices::SeedComponents::Protein::show_coupling_evidence($fig,$cgi,$pegID));
        } elsif ($request eq "abstract_coupling") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::show_abstract_coupling_evidence($fig,$cgi,$pegID));
        } elsif ($request eq "ec_to_maps") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::show_ec_to_maps($fig,$cgi));
        } elsif ($request eq "link_to_map") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::link_to_map($fig,$cgi));
        } elsif ($request eq "fusions") {
            $to->add(results => &FigWebServices::SeedComponents::Protein::show_fusions($fig,$cgi,$pegID));
        } else {
	    # this has to be done to support calls to previous or next peg
	    my $adjust = $cgi->param('previous PEG') ? -1 : $cgi->param('next PEG') ? 1 : 0;
	    if ( $adjust ) {
		my ( $prefix, $protnum ) = $pegID =~ /^(.*\.)(\d+)$/;
		if ( $prefix && $protnum ) {
		    my $prot2 = $prefix . ($protnum + $adjust);
		    if ( $fig->translatable($prot2 ) ) {
			$pegID = $prot2;
			$cgi->delete('prot');
			$cgi->param(-name => 'prot', -value => $pegID);
			$parameters->{peg_id} = $pegID;
		    }
		}
		( $adjust < 0 ) && $cgi->delete('previous PEG');
		( $adjust > 0 ) && $cgi->delete('next PEG');
	    }

	    # initialize the return value variable
	    my $retval;

            # normal page shown.
	    $retval = FigWebServices::SeedComponents::Protein::get_title($parameters);
            $to->add(title => "<br/>".$retval->{body});
            $to->add(assign => "<br/><br/>".FigWebServices::SeedComponents::Protein::get_current_assignment($parameters));
            $to->add("<hr/>") if $to->raw;
            $to->add(translink => FigWebServices::SeedComponents::Protein::get_translation_link());
            $to->add("<hr/>") if $to->raw;
            $to->add(context_graphic => FigWebServices::SeedComponents::Protein::get_peg_view($parameters));
	    $parameters->{initial_value} = 'expanded';
	    $retval = FigWebServices::SeedComponents::Protein::get_chromosome_context($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(context_table => "<br/><br/>".$retval->{title} . "<br/><br/>" . $retval->{body});
            $to->add("<br />") if $to->raw;
            $to->add(annotation_links => FigWebServices::SeedComponents::Protein::get_annotation_links($parameters));
            $to->add("<hr/>") if $to->raw;
            $parameters->{initial_value} = 'expanded';
	    $retval = FigWebServices::SeedComponents::Protein::get_subsystem_connections($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(subsys_connections => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_aa_sequence($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(protein_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(dna_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_dna_sequence_adjacent($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(flanked_sequence => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'expanded';
	    $retval = FigWebServices::SeedComponents::Protein::get_assignments_for_identical_proteins($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(related_assignments => "<br/><br/>". $retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_links($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(subsys_links => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_functional_coupling($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(couplings => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_attributes($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(attributes => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $parameters->{initial_value} = 'collapsed';
	    $retval = FigWebServices::SeedComponents::Protein::get_protein_families($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(families => "<br/><br/>".$retval->{button} . "&nbsp;&nbsp;" . $retval->{title} . "<br/><br/>" . $retval->{body});
            $to->add("<br/><hr/>") if $to->raw;
            $to->add(compared_regions => FigWebServices::SeedComponents::Protein::get_compared_regions($parameters));
            $to->add("<hr/>") if $to->raw;
            $to->add(pubmed_url => FigWebServices::SeedComponents::Protein::get_pubmed_url($parameters));
            $to->add("<br/><hr/>") if $to->raw;
            if (is_sprout($cgi)) {
                $to->add(similarities => FigWebServices::SeedComponents::Protein::get_bbhs($parameters));
            } else {
		$parameters->{initial_value} = 'expanded';
		$retval = FigWebServices::SeedComponents::Protein::get_similarities($parameters);
		delete($parameters->{title});
		delete($parameters->{id});
                $to->add(similarities => $retval->{title} . "<br/><br/>" . $retval->{form} . "<br/>" . $retval->{body});
            }
            $to->add("<br/><hr/>") if $to->raw;
	    $parameters->{initial_value} = 'expanded';
	    $retval = FigWebServices::SeedComponents::Protein::get_tools($parameters);
	    delete($parameters->{title});
	    delete($parameters->{id});
            $to->add(tools => $retval->{body});
            $parameters->{noheadline} = undef;
        }

        $to->add("<br/><hr/>" . FigWebServices::SeedComponents::Protein::get_index_link()) if $to->raw;
        
        print $to->finish();
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3