[Bio] / Sprout / SHDrugSearch.pm Repository:
ViewVC logotype

Diff of /Sprout/SHDrugSearch.pm

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

revision 1.7, Fri May 11 06:30:48 2007 UTC revision 1.9, Mon Jul 16 20:04:51 2007 UTC
# Line 4  Line 4 
4    
5      use strict;      use strict;
6      use Tracer;      use Tracer;
     use SearchHelper;  
7      use CGI;      use CGI;
8      use HTML;      use HTML;
9      use Sprout;      use Sprout;
10      use FeatureData;      use RHLigands;
11      use FeatureQuery;      use base 'SearchHelper';
   
     our @ISA = qw(SearchHelper);  
12    
13  =head1 Drug Target PDB Docking Results Search Helper  =head1 Drug Target PDB Docking Results Search Helper
14    
# Line 152  Line 149 
149      # See if there's already a PDB selected.      # See if there's already a PDB selected.
150      my $defaultPDB = $cgi->param('PDB');      my $defaultPDB = $cgi->param('PDB');
151      # Create the PDB selection strings.      # Create the PDB selection strings.
152      my @pdbStrings = map { "$_->[0], $_->[1] docking results" } @pdbData;      my %pdbStrings = map { $_->[0] => "$_->[0], $_->[1] docking results" } @pdbData;
153        my @pdbNames = map { $_->[0] } @pdbData;
154      # Compute the number of rows to display in the selection list.      # Compute the number of rows to display in the selection list.
155      my $rowCount = (scalar(@pdbStrings) < 20 ? scalar(@pdbStrings) : 20);      my $rowCount = (scalar(@pdbNames) < 20 ? scalar(@pdbNames) : 20);
156      # Convert the PDB list into a selection list.      # Convert the PDB list into a selection list.
157      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbStrings,      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbNames,
158                                    -labels => \%pdbStrings,
159                                  -default => $defaultPDB, -rows => $rowCount);                                  -default => $defaultPDB, -rows => $rowCount);
160      # Build a table from the PDB list and the submit row.      # Build a table from the PDB list and the submit row.
161      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),
# Line 195  Line 194 
194      if (! $pdbID) {      if (! $pdbID) {
195          $self->SetMessage("No PDB specified.");          $self->SetMessage("No PDB specified.");
196      } else {      } else {
197            # Get the ligand result helper.
198            my $rhelp = RHLigands->new();
199            # Set the default output columns.
200            $self->DefaultColumns($rhelp);
201            # Add the extra columns, most of which are taking from DocksWith.
202            $rhelp->AddExtraColumn(energy        => undef, title => 'Total Energy',  style => 'rightAlign', download => 'num');
203            $rhelp->AddExtraColumn(electrostatic => undef, title => 'Electrostatic', style => 'rightAlign', download => 'num');
204            $rhelp->AddExtraColumn(vanderwaals   => undef, title => 'Van der Waals', style => 'rightAlign', download => 'num');
205            $rhelp->AddExtraColumn(tool          => undef, title => 'Tool',          style => 'leftAlign',  download => 'text');
206          # Initialize the session file.          # Initialize the session file.
207          $self->OpenSession();          $self->OpenSession($rhelp);
208          # Initialize the result counter.          # Initialize the result counter.
209          $retVal = 0;          $retVal = 0;
210          PrintLine("Finding docking results for $pdbID.");          $self->PrintLine("Finding docking results for $pdbID.");
211          # Get a query that will return the docking results for this PDB.          # Get a query that will return the docking results for this PDB.
212          my $query= $sprout->Get(['DocksWith', 'Ligand'],          my $query= $sprout->Get(['DocksWith', 'Ligand'],
213                                  "DocksWith(from-link) = ?",                                  "DocksWith(from-link) = ? ORDER BY DocksWith(total-energy)",
214                                  [$pdbID]);                                  [$pdbID]);
215          # Write the column headers.          # Write the column headers.
216          $self->WriteColumnHeaders("ZINC ID", "Ligand", "Total Energy", "Electrostatic", "Van der Waals", "Tool");          $self->PrintLine("Processing results.");
         PrintLine("Processing results.");  
         my $rowCount = 0;  
217          # Loop through the results.          # Loop through the results.
218          while (my $record = $query->Fetch()) {          while (my $record = $query->Fetch()) {
219              # Get the data for this row.              # Get the data for this row.
220              my @data = $record->Values(['Ligand(id)', 'Ligand(name)', 'DocksWith(electrostatic-energy)',              my ($id, $total, $electro, $vander, $tool) = $record->Values(['Ligand(id)',
221                                          'DocksWidth(vanderwaals-energy)', 'DocksWith(tool)']);                                                                            'DocksWith(total-energy)',
222              # Write it to the session file.                                                                            'DocksWith(electrostatic-energy)',
223              $self->WriteColumnData(@data);                                                                            'DocksWith(vanderwalls-energy)',
224                                                                              'DocksWith(tool)']);
225                # Format the energy results so they don't look so awful.
226                ($total, $electro, $vander) = map { sprintf('%.2f', $_) } ($total, $electro, $vander);
227                # Put the extra columns.
228                $rhelp->PutExtraColumns(total => $total, electrostatic => $electro, vanderwaals => $vander,
229                                        tool => $tool);
230                # Finally, we must compute the sort key. We're getting the records in the correct order, so
231                # the sort key is the ordinal of this record, which we are keeping in $retVal.
232                my $key = $retVal;
233                # Write everything to the session file.
234                $rhelp->PutData($key, $id, $record);
235              # See if we need to update the user.              # See if we need to update the user.
236              $rowCount++;              $retVal++;
237              if ($rowCount % 1000 == 0) {              if ($retVal % 1000 == 0) {
238                  PrintLine("$rowCount ligands processed.");                  $self->PrintLine("$retVal ligands processed.");
239              }              }
240          }          }
241            Trace("$retVal rows processed.") if T(3);
242          # Close the session file.          # Close the session file.
243          $self->CloseSession();          $self->CloseSession();
244      }      }
# Line 228  Line 246 
246      return $retVal;      return $retVal;
247  }  }
248    
 =head3 DefaultFeatureColumns  
   
 C<< my @cols = $shelp->DefaultFeatureColumns(); >>  
   
 This method returns a list of the descriptors for the columns to be  
 displayed by this search, overriding the standard column set.  
   
 =cut  
   
 sub DefaultFeatureColumns {  
     # Get the parameters.  
     my ($self) = @_;  
     # Return the result.  
     return qw(orgName function protlink);  
 }  
   
249  =head3 Description  =head3 Description
250    
251  C<< my $htmlText = $shelp->Description(); >>  C<< my $htmlText = $shelp->Description(); >>
# Line 258  Line 260 
260      # Get the parameters.      # Get the parameters.
261      my ($self) = @_;      my ($self) = @_;
262      # Return the result.      # Return the result.
263      return "Show the PDB and gene relationships for a specified drug target analysis project.";      return "Show the docking results for a specific PDB.";
264  }  }
265    
266  =head3 SearchTitle  =head3 SearchTitle
# Line 282  Line 284 
284      return $retVal;      return $retVal;
285  }  }
286    
 =head3 DownloadFormatAvailable  
   
 C<< my $okFlag = $shelp->DownloadFormatAvailable($format); >>  
   
 This method returns TRUE if a specified download format is legal for this type of search  
 and FALSE otherwise. For any feature-based search, there is no need to override this  
 method.  
   
 =over 4  
   
 =item format  
   
 Download format type code.  
   
 =item RETURN  
   
 Returns TRUE if the download format is legal for this search and FALSE otherwise.  
   
 =back  
   
 =cut  
   
 sub DownloadFormatAvailable {  
     # Get the parameters.  
     my ($self, $format) = @_;  
     # Declare the return variable.  
     my $retVal = ($format eq 'tbl');  
     # Return the result.  
     return $retVal;  
 }  
   
   
287  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3