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

View of /FigWebServices/figfam_proto.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (annotate)
Thu Feb 22 20:45:16 2007 UTC (12 years, 9 months ago) by mkubal
Branch: MAIN
prototype domain analysis of protein sets

# -*- perl -*-

use FIG;
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 @set,$count,%domain;

    if($figfam_id){
	@set = $fig->proteins_in_family($figfam_id);
	$count = scalar(@set);
	foreach $peg(@set){
	    $returns = $fig->get_attributes($peg);
	    foreach $return (@$returns){
		if(@$return[1] =~/CDD::(\d+)/){
		    $id = $1;
		    if($domain{$id}){$domain{$id} = $domain{$id} + 1;}
		    else{$domain{$id} = 1;}
		}
	    }
        }
	
	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