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

Diff of /FigWebServices/targets.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5, Thu Dec 7 00:36:39 2006 UTC revision 1.6, Mon Dec 11 19:49:44 2006 UTC
# Line 8  Line 8 
8  use strict;  use strict;
9  use Tracer;  use Tracer;
10  use CGI;  use CGI;
 use Sprout;  
11  use SHDrugSearch;  use SHDrugSearch;
12    use FIGRules;
13    
14  my $odd = 1;  my $odd = 1;
15  my @styles = ("even", "odd");  my @styles = ("even", "odd");
16  my $lkpdb ='http://www.rcsb.org/pdb/explore.do?structureId=';  my $lkpdb ='http://www.rcsb.org/pdb/explore.do?structureId=';
17  my $fig = new FIG;  my $fig = new FIG;
   
18  my ($cgi, $varHash) = ScriptSetup();  my ($cgi, $varHash) = ScriptSetup();
19  #get the query paramaters  #get the query paramaters
20  my $target = $cgi->param("target");  my $target = $cgi->param("target");
21  my $uctarget = ucfirst $target;  my $uctarget = ucfirst $target;
22    my %pegHash;
23    
24  eval {  eval {
25      my $org = $cgi->param("org");      my $org = $cgi->param("org");
# Line 28  Line 28 
28      $varHash->{target} = $target;      $varHash->{target} = $target;
29      $varHash->{uc_first_target} = ucfirst $target;      $varHash->{uc_first_target} = ucfirst $target;
30      $varHash->{org} = $org;      $varHash->{org} = $org;
31        # Compute the peg hash if we're organism-only.
32        if ($org && ! $target) {
33            %pegHash = get_attribute_hash($org);
34        }
35      #The script operates      #The script operates
36      &add_table_top($cgi, $varHash, $org);      &add_table_top($cgi, $varHash, $org);
37      if ($target){      if ($target){
# Line 52  Line 56 
56      &add_words($cgi, $varHash, $org);      &add_words($cgi, $varHash, $org);
57      if($target){      if($target){
58          $varHash->{result} .= ' <table width="90%" class="targets">          $varHash->{result} .= ' <table width="90%" class="targets">
59             <tr class=odd><th>Organism</th><th>Functional Role</th><th>Candidacy<th>PDB</th></tr>';             <tr class=odd><th>Organism</th><th>Functional Role</th><th>Candidacy<th>PDB</th><th>Best Hit to Human</th></tr>';
60      }else{      }elsif ($org) {
61          $varHash->{result} .= '<table width="90%" class="targets">          $varHash->{result} .= '<table width="90%" class="targets">
62           <tr class=odd><th>Organism</th><th>Functional Role</th><th>Category</th><th>PDB</th></tr>';           <tr class=odd><th>Organism</th><th>Functional Role</th><th>Category</th><th>PDB</th><th>Best Hit to Human</th></tr>';
63      }      }
64  }  }
65    
# Line 95  Line 99 
99      my $link = '../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=';      my $link = '../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=';
100      my $org = $cgi->param('org');      my $org = $cgi->param('org');
101      Trace("Printing $color for $pdb.") if T(4);      Trace("Printing $color for $pdb.") if T(4);
102        # We'll put the category/attribute column value in here if this row should be
103        # displayed.
104        my $caColumn;
105      if ($org && $target){      if ($org && $target){
106          if ($peg =~ m/$org/){          if ($peg =~ m/$org/){
107              $odd = 1 - $odd;              $caColumn = "<td><a href=\"$lit\">$cat</a></td>\n";
             $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><em>$which</em><br>$peg</td>\n";  
             $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";  
             $varHash->{result} .= "<td><a href=\"$lit\">$cat</a></td>\n";  
             $varHash->{result} .= "<td color=\"$color\"><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";  
108          }          }
109      }elsif($target){      }elsif($target){
110          $odd = 1 - $odd;          $caColumn = "<td><a href=\"$lit\">$cat</a></td>\n";
         $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><a href=\"$selfURL?org=$genome&target=$target\"><em>$which</em></a><br>$peg</td>\n";  
         $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";  
         $varHash->{result} .= "<td><a href=\"$lit\">$cat</a></td>\n";  
         $varHash->{result} .= "<td color=\"$color\"><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";  
111      }elsif($org){      }elsif($org){
112            if ($pegHash{$peg}) {
113                $caColumn = $pegHash{$peg};
114            } else {
115                $caColumn = "<td><a href=\"../content/contactus.php\">Suggest</a></td>\n";
116            }
117        }
118        if (defined $caColumn) {
119          $odd = 1 - $odd;          $odd = 1 - $odd;
120          $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><em>$which</em><br>$peg</td>\n";          $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><em>$which</em><br>$peg</td>\n";
121          $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";          $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";
122          &get_attribute($cgi, $varHash, $peg, $genome);          $varHash->{result} .= $caColumn;
123          $varHash->{result} .= "<td color=$color><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";          $varHash->{result} .= "<td color=\"$color\"><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";
124            # Find the best hit to a human.
125            my @bbhList = FIGRules::BatchBBHs($peg, 1e-15, '9606.3');
126            if (@bbhList) {
127                # Here we found one, so get the best one in the list.
128                my @sorted = sort { $a->[2] <=> $b->[2] } @bbhList;
129                my $bestPeg = $sorted[0]->[1];
130                $varHash->{result} .= "<td><a href=\"../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=$bestPeg\">$sorted[0]->[2]</a></td>\n";
131            } else {
132                $varHash->{result} .= "<td>&nbsp;</td>\n";
133      }      }
134  }  }
135    }
136    
137    
138  # This sub changes the Candidacy code to something meaningful.  # This sub changes the Candidacy code to something meaningful.
139  sub changecat{  sub changecat{
# Line 126  Line 143 
143      return $cat;      return $cat;
144  }  }
145    
146  # This sub determines if a peg has an atribute  # This sub determines the attributes of each peg related to the given genome.
147  sub get_attribute{  sub get_attribute_hash {
148      my ($cgi, $varHash, $peg, $genome) = @_;      my ($genome) = @_;
149      my %files = (drug => "drug.txt", toxin => "toxin.txt", vaccine => "vaccine.txt");      my %files = (drug => "drug.txt", toxin => "toxin.txt", vaccine => "vaccine.txt");
150        my %retVal;
151      my $selfURL = $cgi->url(-relative => 1);      my $selfURL = $cgi->url(-relative => 1);
152      for my $key (keys %files) {      for my $key (keys %files) {
153          Open(\*DATA, "$FIG_Config::drug_directory/$files{$key}");          Open(\*INFILE, "$FIG_Config::drug_directory/$files{$key}");
154          while (<DATA>){          while (! eof(INFILE)){
155              my @lines = split (/\r/,$_);              my @entry = Tracer::GetLine(\*INFILE);
156              foreach(@lines){              if ($entry[5] =~ /$genome/){
                 my @entry = split(/\t/,$_);  
                 if ("$entry[5]" eq "$peg"){  
157                      my $title = ucfirst $key;                      my $title = ucfirst $key;
158                      $varHash->{result} .= "<td><a href=$selfURL?org=$genome&target=$key>$title</a></td>\n";                  $retVal{$entry[5]} = "<td><a href=$selfURL?org=$genome&target=$key>$title</a></td>\n";
                     return;  
159                  }                  }
160              }              }
161            close(INFILE);
162          }          }
         close(DATA);  
     }  
     $varHash->{result} .= "<td><a href=\"../content/contactus.php\">Suggest</a></td>\n";  
     return;  
163  }  }
164    
165  #-- we wish to desplay only the best pdbs and those that are relavent  #-- we wish to desplay only the best pdbs and those that are relavent

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3