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

View of /FigWebServices/figfam_proto.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Thu Feb 22 23:06:08 2007 UTC (12 years, 9 months ago) by mkubal
Branch: MAIN
Changes since 1.1: +24 -14 lines
faster

# -*- perl -*-

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

$fig = new FIG;
my $html = [];

unshift(@$html, "<TITLE>Domain Analysis of Protein Sets</TITLE>\n");

my $inputs;
if ($cgi->param('request') ) 
{
  my $input =$cgi->param('proteins');
  my @inputs = split("\n",$input);

  if ($cgi->upload('fileupload'))
  {
     my $fh=$cgi->upload('fileupload');
     @inputs = <$fh> ;
  }

  $given = [@inputs];
  &analyze_domains($cgi,$fig,$given); 
 
}
else
{
  &show_initial($fig,$cgi,$html);
  &HTML::show_page($cgi,$html,1);
  exit;
}

sub show_initial {
    my ($fig,$cgi,$html)=@_;
    push @$html, 
    $cgi->start_multipart_form(),
    "<h3>Enter FigFam ID</h3>",
    $cgi->textarea(-name=>"figfam_id", -rows=>1, -columns=>20),
    $cgi->br,
    "<h3>Enter set of pegs</h3>\n",
    $cgi->textarea(-name=>"set_of_pegs", -rows=>10, -columns=>40), 
    $cgi->br,  
    "<h3>Upload File</h3>",
    $cgi->filefield(-name=>"fileupload", -size=>50),
    $cgi->br,
    $cgi->hr,
    $cgi->submit(-name=>'request', -value=>'Submit for Domain Analysis'),
    $cgi->reset, $cgi->end_form;
    return $html;
}

sub analyze_domains 
{
    my ($cgi,$fig,$given) =@_;

    my $sops = $cgi->param('set_of_pegs');
    my $figfam_id = $cgi->param('figfam_id');
    my $figfam = FigFam->new($fig,$figfam_id);
    my $count;
    my %domain;

    if($figfam_id){
	my $set = $figfam->pegs_of();
	$count = scalar(@$set);
	my $found = 0;
        foreach my $peg (@$set){
            #if($found){last;}
	    if($peg =~/fig\|/){  
		my @returns = $fig->get_attributes($peg,'CDD');
		foreach $return (@returns){
		    if(@$return[1] =~/(\d+)/){
			my $id = $1;
			if($domain{$id}){$domain{$id} = $domain{$id} + 1;}
			else{
			    $domain{$id} = 1; 
			    $found = 1;
			}
			last;
		    }
		}
	    }
	}
	
	push @$html,
	"<h3>Domain Analysis Results</h3>",
	"<br>",
	"<table>";
	foreach $dom (keys(%domain)){
	    $instances = $domain{$dom};
	    push @$html,"<tr><td>$dom</td><td>$instances</td></tr>";
	}
	push @$html,"</table>";
	
	&HTML::show_page($cgi,$html,1);
	exit;
    }
    else{
	push @$html, 
	"<h3>Must enter either FigFam ID or set of pegs</h3>";
	&HTML::show_page($cgi,$html,1);
	exit;
    }

}


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3