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

View of /FigWebServices/kernel.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (download) (annotate)
Mon Dec 5 19:12:12 2005 UTC (13 years, 11 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.14: +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.
#


use CGI;

if (-f "$FIG_Config::data/Global/why_down")
{
    local $/;
    open my $fh, "<$FIG_Config::data/Global/why_down";
    my $down_msg = <$fh>;
    
    print CGI::header();
    print CGI::head(CGI::title("SEED Server down"));
    print CGI::start_body();
    print CGI::h1("SEED Server down");
    print CGI::p("The seed server is not currently running:");
    print CGI::pre($down_msg);
    print CGI::end_body();
    exit;
}

use FIG;
my $fig = new FIG;

use HTML;
use strict;
use GenoGraphics;
use CGI;
my $cgi = new CGI;

# for somethings we just want to print out plain text
if ($cgi->param('plaintext')) {
 print $cgi->header("text/text");
}
else { 
 print $cgi->header;
 print "<pre>\n";
}

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

my $request = $cgi->param('request');

if ($request eq "genomes")
{
    my(@genomes,$all);
    $all = $cgi->param('all');
    if ($all)
    {
	@genomes = $fig->genomes();
    }
    else
    {
	@genomes = $fig->genomes("complete");
    }
    my $genome;

    foreach $genome (@genomes)
    {
	print $genome,"\t",$fig->genus_species($genome),"\n";
    }
}
elsif ($request =~ /^possibly_truncated\(([^\)]+)\)\s*/)
{
    my $peg = $1;
    my $val = $fig->possibly_truncated($peg) ? 1 : 0;
    print "$val\n";
}
elsif ($request =~ /^\s*best_bbh_candidates\((\d+\.\d+),([^,]+),(\d+),\[(fig\|\d+\.\d+\.peg\.\d+(,fig\|\d+\.\d+\.peg\.\d+)*)(,([^\]]+))?\]\)\s*$/)
{
    my($genome,$cutoff,$requested,$known) = ($1,$2,$3,$4);
    my $frac_match = $6 ? $6 : 0.7;
    foreach $_ ($fig->best_bbh_candidates($genome,$cutoff,$requested,[split(/,/,$known)],$frac_match))
    {
	my($peg,$bbh,$psc) = @$_;
	print join("\t",($peg,$bbh,$psc,scalar $fig->function_of($peg),scalar $fig->function_of($bbh))),"\n";
    }
}
elsif ($request =~ /^\s*external_calls\(\[(fig\|\d+\.\d+\.peg\.\d+(,fig\|\d+\.\d+\.peg\.\d+)*)\]\)\s*$/)
{
    my $pegs = [split(/,/,$1)];
    print join("\n",map { join("\t",@$_) } $fig->external_calls($pegs)),"\n";
}
elsif($request =~ /^\s*same_func\(([^,]+),(.+)\)\s*$/)
{
    print $fig->same_func($1,$2),"\n";
}
elsif ($request eq "all_maps")
{
    my @maps = $fig->all_maps;
    my $map;
    foreach $map (@maps)
    {
	print $map,"\t",$fig->map_name($map),"\n";
    }
}
elsif ($request eq "all_subsystems")
{
    my @subs = $fig->all_subsystems;
    my $sub;
    foreach $sub (@subs)
    {
	print "$sub\n";
    }
}
elsif ($request eq "all_constructs")
{
    my @subs = $fig->all_subsystems;
    my $sub;
    my $subdir = "$FIG_Config::data/Subsystems";
    foreach $sub (@subs)
    {
	my $f = "$subdir/$sub/constructs";
	if (open(my $fh, "<$f"))
	{
	    print "$sub\n";

	    while (<$fh>)
	    {
		print;
	    }
	    close($fh);
	    print "//\n";
	}
    }
}
elsif ($request =~ /^map_to_ecs\((.*)\)$/)
{
    my @ecs = $fig->map_to_ecs($1);
    my $ec;
    foreach $ec (@ecs)
    {
	print $ec,"\t",$fig->ec_name($ec),"\n";
    }
}
elsif ($request =~ /^subsystem_to_roles\((.*)\)$/)
{
    my @roles = $fig->subsystem_to_roles($1);
    my $role;
    foreach $role (@roles)
    {
	print "$role\n";
    }
}
elsif ($request =~ /^catalyzes\((.*)\)$/)
{
    my $ec = $1;
    my $rid;
    foreach $rid ($fig->catalyzes($ec))
    {
	print "$rid\t",$fig->displayable_reaction($rid),"\n";
    }
}
elsif ($request =~ /^comp2react\((C\d+)\)$/)
{
    my $cid = $1;
    my $rid;
    foreach $rid ($fig->comp2react($cid))
    {
	print $fig->displayable_reaction($rid),"\n";
    }
}
elsif ($request =~ /^all_compounds$/)
{
    my($cid);
    foreach $cid ($fig->all_compounds)
    {
	my(@tmp) = sort { length($a) <=> length($b) } $fig->names_of_compound($cid);
	print "$cid\t$tmp[0]\n";
    }
}
elsif ($request =~ /^all_roles$/)
{
    my $x;
    foreach $x ($fig->all_roles)
    {
	print join("\t",@$x),"\n";
    }
}
elsif ($request =~ /^all_reactions$/)
{
    my($rid,$tuple,@ecs,$rev);
    foreach $rid ($fig->all_reactions)
    {
	@ecs = $fig->catalyzed_by($rid);
	$rev = $fig->reversible($rid) ? 1 : 0;
	print "$rid\t",join(",",@ecs),"\t$rev\n";
	foreach $tuple ($fig->reaction2comp($rid,0))
	{
	    print "\t",join("\t",@$tuple),"\t0\n";
	}

	foreach $tuple ($fig->reaction2comp($rid,1))
	{
	    print "\t",join("\t",@$tuple),"\t1\n";
	}
    }
}
elsif ($request =~ /^reaction2comp\((R\d+),(\d)\)$/)
{
    my($rid,$set) = ($1,$2);
    my $tuple;
    foreach $tuple ($fig->reaction2comp($rid,$set))
    {
	print join("\t",@$tuple),"\n";
    }
}
elsif ($request =~ /^seqs_with_roles_in_genomes\(\[([^\]]+)\],\[([^\]]+)\],([^)]+)\)/)
{
    my($genomes,$roles,$who) = ($1,$2,$3);
    my @genomes = split(/,/,$genomes);
    my @roles = split(/,/,$roles);
    my $result = $fig->seqs_with_roles_in_genomes([@genomes],[@roles],$who);
    my $genome;
    foreach $genome (sort { $a <=> $b } keys(%$result))
    {
	my $for_one_genome = $result->{$genome};
	my $role;
	foreach $role (sort keys(%$for_one_genome))
	{
	    my $x = $for_one_genome->{$role};
	    my $pair;
	    foreach $pair (sort { $a->[0] cmp $b->[0] } @$x)
	    {
		my($peg,$func) = @$pair;
		print "$genome\t$role\t$peg\t$func\n";
	    }
	}
    }
}
elsif ($request =~ /^candidates_for_role\(\'([^\']+)\',(\d+\.\d+),([^\)]+)\)$/)
{
    my($role,$genome,$cutoff) = ($1,$2,$3);
    my @result = $fig->candidates_for_role($role,$genome,$cutoff,"master");
    my $peg;
    foreach $peg (@result)
    {
	my $func = $fig->function_of($peg);
	$func = $func ? $func : "hypothetical protein";
	print join("\t",($genome,$role,$peg,$func)),"\n";
    }
}
elsif ($request =~ /^sims\(([^,]+),(\d+),([^,]+),([^,]+)\)$/)
{
    my($peg,$maxN,$maxP,$select) = ($1,$2,$3,$4);
    my @sims = $fig->sims($peg,$maxN,$maxP,$select);
    my $sim;
    foreach $sim (@sims)
    {
	my $func = $fig->function_of($sim->id2);
	$func = $func ? $func : "hypothetical protein";
	print join("\t",($sim->id1,$sim->ln1,$sim->id2,$sim->ln2,$sim->iden,$sim->psc,$sim->b1,$sim->e1,$sim->b2,$sim->e2,$func)),"\n";
    }
}
elsif ($request =~ /^readout_one_org_by_subsystem\(([^\)]+)\)/)
{
    my $genome = $1;
    my $gs     = $fig->genus_species($genome);
    print "$genome\t$gs\n";
    
    my @subsystems = $fig->all_subsystems;
    my $subsystem;
    foreach $subsystem (@subsystems)
    {
	print "\t$subsystem\n";
	my @roles = $fig->subsystem_to_roles($subsystem);

	my $result = $fig->seqs_with_roles_in_genomes([$genome],[@roles],"master");
	my $role_hash = $result->{$genome};
        my $role;
	foreach $role (sort keys(%$role_hash))
	{
	    print "\t\t$role\t",$fig->ec_name($role),"\n";
	    my $x = $role_hash->{$role};
	    my $pair;
	    foreach $pair (@$x)
	    {
		my($peg,$func) = @$pair;
		print "\t\t\t$peg\t$func\n";
	    }
	}
    }
}
elsif ($request =~ /^readout_one_org\(([^\)]+)\)/)
{
    my $genome = $1;
    my $gs     = $fig->genus_species($genome);
    print "$genome\t$gs\n";
    
    my @maps = $fig->all_maps;
    my $map;
    foreach $map (@maps)
    {
	print "\t$map\t",$fig->map_name($map),"\n";
	my @ecs = $fig->map_to_ecs($map);

	my $result = $fig->seqs_with_roles_in_genomes([$genome],[@ecs],"master");
	my $role_hash = $result->{$genome};
        my $role;
	foreach $role (sort keys(%$role_hash))
	{
	    print "\t\t$role\t",$fig->ec_name($role),"\n";
	    my $x = $role_hash->{$role};
	    my $pair;
	    foreach $pair (@$x)
	    {
		my($peg,$func) = @$pair;
		print "\t\t\t$peg\t$func\n";
	    }
	}
    }
}
elsif ($request eq "nr") {
 # dump out the local nr
 open(IN, "$FIG_Config::global/nr") || die "Can't open $FIG_Config::global/nr";
 print while (<IN>);
}
else {
 print<<EOF;
Valid requests:
  genomes
  possibly_truncated
  best_bbh_candidates
  external_calls
  same_func
  all_maps
  all_subsystems
  all_constructs
  map_to_ecs
  subsystem_to_roles
  catalyzes
  comp2react
  all_compounds
  all_roles
  all_reactions
  reaction2comp
  seqs_with_roles_in_genomes
  candidates_for_role
  sims
  readout_one_org_by_subsystem
  readout_one_org
  nr
EOF
}

unless ($cgi->param('plaintext')) {print "</pre>\n"}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3