[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.4, Wed Dec 6 23:50:46 2006 UTC revision 1.7, Tue Apr 10 04:08:15 2007 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            Trace("Computing peg hash.") if T(3);
34            %pegHash = get_attribute_hash($org);
35        }
36      #The script operates      #The script operates
37      &add_table_top($cgi, $varHash, $org);      &add_table_top($cgi, $varHash, $org);
38      if ($target){      if ($target){
# Line 52  Line 57 
57      &add_words($cgi, $varHash, $org);      &add_words($cgi, $varHash, $org);
58      if($target){      if($target){
59          $varHash->{result} .= ' <table width="90%" class="targets">          $varHash->{result} .= ' <table width="90%" class="targets">
60             <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>';
61      }else{      }elsif ($org) {
62          $varHash->{result} .= '<table width="90%" class="targets">          $varHash->{result} .= '<table width="90%" class="targets">
63           <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>';
64      }      }
65  }  }
66    
# Line 73  Line 78 
78  sub get_table{  sub get_table{
79      my($cgi, $varHash, $file)= @_;      my($cgi, $varHash, $file)= @_;
80      Open(\*TABLE, "<$FIG_Config::drug_directory/$file");      Open(\*TABLE, "<$FIG_Config::drug_directory/$file");
81        Trace("Processing table $file.") if T(3);
82      while (! eof TABLE){      while (! eof TABLE){
83          my @entry = Tracer::GetLine(\*TABLE);          my @entry = Tracer::GetLine(\*TABLE);
84          &get_best_pdb($cgi, $varHash, @entry);          &get_best_pdb($cgi, $varHash, @entry);
# Line 93  Line 99 
99      my $selfURL = $cgi->url(-relative => 1);      my $selfURL = $cgi->url(-relative => 1);
100      my $link = '../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=';      my $link = '../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=';
101      my $org = $cgi->param('org');      my $org = $cgi->param('org');
102      Trace("Printing $color for $pdb.") if T(4);      Trace("Printing $color for $pdb of peg $peg.") if T(4);
103        # We'll put the category/attribute column value in here if this row should be
104        # displayed.
105        my $caColumn;
106      if ($org && $target){      if ($org && $target){
107          if ($peg =~ m/$org/){          if ($peg =~ m/$org/){
108              $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";  
109          }          }
110      }elsif($target){      }elsif($target){
111          $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";  
112      }elsif($org){      }elsif($org){
113            Trace("Peg hash is: $pegHash{$peg}.") if T(4);
114            if ($pegHash{$peg}) {
115                $caColumn = $pegHash{$peg};
116            } else {
117                $caColumn = "<td></td>\n"; # <a href=\"../content/contactus.php\">Suggest</a></td>\n";
118            }
119        }
120        if (defined $caColumn) {
121          $odd = 1 - $odd;          $odd = 1 - $odd;
122          $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";
123          $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";          $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";
124          &get_attribute($cgi, $varHash, $peg, $genome);          $varHash->{result} .= $caColumn;
125          $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";
126            # Find the best hit to a human.
127            my @bbhList = FIGRules::BatchBBHs($peg, 1e-15, '9606.3');
128            if (@bbhList) {
129                # Here we found one, so get the best one in the list.
130                my @sorted = sort { $a->[2] <=> $b->[2] } @bbhList;
131                my $bestPeg = $sorted[0]->[1];
132                $varHash->{result} .= "<td><a href=\"../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=$bestPeg\">$sorted[0]->[2]</a></td>\n";
133            } else {
134                $varHash->{result} .= "<td>&nbsp;</td>\n";
135            }
136      }      }
137  }  }
138    
139    
140  # This sub changes the Candidacy code to something meaningful.  # This sub changes the Candidacy code to something meaningful.
141  sub changecat{  sub changecat{
142      my($dog) = @_;      my($dog) = @_;
143      Trace("Selecting category for $dog.") if T(3);      Trace("Selecting category for $dog.") if T(4);
144      my $cat = SHDrugSearch::GetCategory($dog);      my $cat = SHDrugSearch::GetCategory($dog);
145      return $cat;      return $cat;
146  }  }
147    
148  # This sub determines if a peg has an atribute  # This sub determines the attributes of each peg related to the given genome.
149  sub get_attribute{  sub get_attribute_hash {
150      my ($cgi, $varHash, $peg, $genome) = @_;      my ($genome) = @_;
151      my %files = (drug => "drug.txt", toxin => "toxin.txt", vaccine => "vaccine.txt");      my %files = (drug => "drug.txt", toxin => "toxin.txt", vaccine => "vaccine.txt");
152        my %retVal;
153      my $selfURL = $cgi->url(-relative => 1);      my $selfURL = $cgi->url(-relative => 1);
154      for my $key (keys %files) {      for my $key (keys %files) {
155          Open(\*DATA, "$FIG_Config::drug_directory/$files{$key}");          Open(\*INFILE, "$FIG_Config::drug_directory/$files{$key}");
156          while (<DATA>){          while (! eof(INFILE)){
157              my @lines = split (/\r/,$_);              my @entry = Tracer::GetLine(\*INFILE);
158              foreach(@lines){              if ($entry[5] =~ /$genome/){
159                  my @entry = split(/\t/,$_);                  Trace("$entry[5] added to hash.") if T(3);
                 if ("$entry[5]" eq "$peg"){  
160                      my $title = ucfirst $key;                      my $title = ucfirst $key;
161                      $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;  
                 }  
162              }              }
163          }          }
164          close(DATA);          close(INFILE);
165      }      }
166      $varHash->{result} .= "<td><a href=\"../content/contactus.php\">Suggest</a></td>\n";      return %retVal;
     return;  
167  }  }
168    
169  #-- 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
170  sub get_best_pdb{  sub get_best_pdb{
171      my ($cgi, $varHash, @entry)= @_;      my ($cgi, $varHash, @entry)= @_;
172      my @pdbresults =("1ah7","1dhn","1tfu"); # we define what pdb actually have been docked well.      my @pdbresults =("1ah7","1dhn","1tfu"); # we define what pdb actually have been docked well.
     if (T(4)) {  
         my $line = "Processing line\n";  
         for (my $i = 0; $i <= $#entry; $i++) {  
             $line .= "$i. $entry[$i]\n";  
         }  
         Trace($line);  
     }  
     Trace("Analyzing PDB $entry[11].") if T(4);  
173      foreach (@pdbresults){ #look through the results we have      foreach (@pdbresults){ #look through the results we have
174          if ($entry[11] =~ m/$_/gi){ #ifwe have results for the free          if ($entry[11] =~ m/$_/gi){ #ifwe have results for the free
175              &print_column($cgi, $varHash, $entry[11],'red', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1]); #we want to display this              &print_column($cgi, $varHash, $entry[11],'red', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1]); #we want to display this

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3