[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.8, Thu May 17 23:43:57 2007 UTC revision 1.11, Thu Dec 6 14:58:03 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 Tracer;
12        use base 'SearchHelper';
     our @ISA = qw(SearchHelper);  
13    
14  =head1 Drug Target PDB Docking Results Search Helper  =head1 Drug Target PDB Docking Results Search Helper
15    
# Line 56  Line 54 
54    
55  =head3 GetCategory  =head3 GetCategory
56    
57  C<< my $description = SHDrugSearch::GetCategory($code); >>      my $description = SHDrugSearch::GetCategory($code);
58    
59  Return the description of the specified category code.  Return the description of the specified category code.
60    
# Line 93  Line 91 
91    
92  =head3 PDBLink  =head3 PDBLink
93    
94  C<< my $pdbHtml = SHDrugSearch::PDBLink($cgi, $pdbID); >>      my $pdbHtml = SHDrugSearch::PDBLink($cgi, $pdbID);
95    
96  This method converts a PDB ID to a hyperlink into the PDB web site.  This method converts a PDB ID to a hyperlink into the PDB web site.
97    
# Line 132  Line 130 
130    
131  =head3 Form  =head3 Form
132    
133  C<< my $html = $shelp->Form(); >>      my $html = $shelp->Form();
134    
135  Generate the HTML for a form to request a new search.  Generate the HTML for a form to request a new search.
136    
# Line 173  Line 171 
171    
172  =head3 Find  =head3 Find
173    
174  C<< my $resultCount = $shelp->Find(); >>      my $resultCount = $shelp->Find();
175    
176  Conduct a search based on the current CGI query parameters. The search results will  Conduct a search based on the current CGI query parameters. The search results will
177  be written to the session cache file and the number of results will be  be written to the session cache file and the number of results will be
# Line 197  Line 195 
195      if (! $pdbID) {      if (! $pdbID) {
196          $self->SetMessage("No PDB specified.");          $self->SetMessage("No PDB specified.");
197      } else {      } else {
198            # Get the ligand result helper.
199            my $rhelp = RHLigands->new($self);
200            # Set the default output columns.
201            $self->DefaultColumns($rhelp);
202            # Add the extra columns, most of which are taking from DocksWith.
203            $rhelp->AddExtraColumn(energy        => undef, title => 'Total Energy',  style => 'rightAlign', download => 'num');
204            $rhelp->AddExtraColumn(electrostatic => undef, title => 'Electrostatic', style => 'rightAlign', download => 'num');
205            $rhelp->AddExtraColumn(vanderwaals   => undef, title => 'Van der Waals', style => 'rightAlign', download => 'num');
206            $rhelp->AddExtraColumn(tool          => undef, title => 'Tool',          style => 'leftAlign',  download => 'text');
207          # Initialize the session file.          # Initialize the session file.
208          $self->OpenSession();          $self->OpenSession($rhelp);
209          # Initialize the result counter.          # Initialize the result counter.
210          $retVal = 0;          $retVal = 0;
211          $self->PrintLine("Finding docking results for $pdbID.");          $self->PrintLine("Finding docking results for $pdbID.");
# Line 207  Line 214 
214                                  "DocksWith(from-link) = ? ORDER BY DocksWith(total-energy)",                                  "DocksWith(from-link) = ? ORDER BY DocksWith(total-energy)",
215                                  [$pdbID]);                                  [$pdbID]);
216          # Write the column headers.          # Write the column headers.
         $self->WriteColumnHeaders("ZINC ID", "Total Energy", "Electrostatic", "Van der Waals", "Tool");  
217          $self->PrintLine("Processing results.");          $self->PrintLine("Processing results.");
218          # Loop through the results.          # Loop through the results.
219          while (my $record = $query->Fetch()) {          while (my $record = $query->Fetch()) {
220              # Get the data for this row.              # Get the data for this row.
221              my ($id, $name, $total, $electro, $vander, $tool) = $record->Values(['Ligand(id)', 'Ligand(name)',              my ($id, $total, $electro, $vander, $tool) = $record->Values(['Ligand(id)',
222                                                                                   'DocksWith(total-energy)',                                                                                   'DocksWith(total-energy)',
223                                                                                   'DocksWith(electrostatic-energy)',                                                                                   'DocksWith(electrostatic-energy)',
224                                                                                   'DocksWith(vanderwalls-energy)',                                                                                   'DocksWith(vanderwalls-energy)',
225                                                                                   'DocksWith(tool)']);                                                                                   'DocksWith(tool)']);
226              # Format the energy results so they don't look so awful.              # Format the energy results so they don't look so awful.
227              my @data = map { sprintf('%.2f', $_) } ($total, $electro, $vander);              ($total, $electro, $vander) = map { sprintf('%.2f', $_) } ($total, $electro, $vander);
228              # Create a tooltip for the ligand name.              # Put the extra columns.
229              my $linkedID = $cgi->a({ href => "http://blaster.docking.org/zinc/srchdbk.pl?zinc=$id;go=Query",              $rhelp->PutExtraColumns(energy => $total, electrostatic => $electro, vanderwaals => $vander,
230                                       title => $name }, $id);                                      tool => $tool);
231              # Finally, we must compute the sort key. We're getting the records in the correct order, so              # Finally, we must compute the sort key. We're getting the records in the correct order, so
232              # the sort key is the ordinal of this record, which we are keeping in $retVal.              # the sort key is the ordinal of this record, which we are keeping in $retVal.
233              my $key = $retVal;              my $key = $retVal;
234              # Write everything to the session file.              # Write everything to the session file.
235              $self->WriteColumnData($retVal, $id, $linkedID, @data, $tool);              $rhelp->PutData($key, $id, $record);
236              # See if we need to update the user.              # See if we need to update the user.
237              $retVal++;              $retVal++;
238              if ($retVal % 1000 == 0) {              if ($retVal % 1000 == 0) {
# Line 241  Line 247 
247      return $retVal;      return $retVal;
248  }  }
249    
 =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);  
 }  
   
250  =head3 Description  =head3 Description
251    
252  C<< my $htmlText = $shelp->Description(); >>      my $htmlText = $shelp->Description();
253    
254  Return a description of this search. The description is used for the table of contents  Return a description of this search. The description is used for the table of contents
255  on the main search tools page. It may contain HTML, but it should be character-level,  on the main search tools page. It may contain HTML, but it should be character-level,
# Line 276  Line 266 
266    
267  =head3 SearchTitle  =head3 SearchTitle
268    
269  C<< my $titleHtml = $shelp->SearchTitle(); >>      my $titleHtml = $shelp->SearchTitle();
270    
271  Return the display title for this search. The display title appears above the search results.  Return the display title for this search. The display title appears above the search results.
272  If no result is returned, no title will be displayed. The result should be an html string  If no result is returned, no title will be displayed. The result should be an html string
# Line 295  Line 285 
285      return $retVal;      return $retVal;
286  }  }
287    
 =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;  
 }  
   
 =head3 ColumnTitle  
   
 C<< my $title = $shelp->ColumnTitle($colName); >>  
   
 Return the column heading title to be used for the specified column name.  
 In this case, we just return the column name unmodified.  
   
 =over 4  
   
 =item colName  
   
 Name of the desired column.  
   
 =item RETURN  
   
 Returns the title to be used as the column header for the named column.  
   
 =back  
   
 =cut  
   
 sub ColumnTitle {  
     my ($self, $colName) = @_;  
     return $colName;  
 }  
   
   
288  1;  1;

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3