[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.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 152  Line 150 
150      # See if there's already a PDB selected.      # See if there's already a PDB selected.
151      my $defaultPDB = $cgi->param('PDB');      my $defaultPDB = $cgi->param('PDB');
152      # Create the PDB selection strings.      # Create the PDB selection strings.
153      my @pdbStrings = map { "$_->[0], $_->[1] docking results" } @pdbData;      my %pdbStrings = map { $_->[0] => "$_->[0], $_->[1] docking results" } @pdbData;
154        my @pdbNames = map { $_->[0] } @pdbData;
155      # Compute the number of rows to display in the selection list.      # Compute the number of rows to display in the selection list.
156      my $rowCount = (scalar(@pdbStrings) < 20 ? scalar(@pdbStrings) : 20);      my $rowCount = (scalar(@pdbNames) < 20 ? scalar(@pdbNames) : 20);
157      # Convert the PDB list into a selection list.      # Convert the PDB list into a selection list.
158      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbStrings,      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbNames,
159                                    -labels => \%pdbStrings,
160                                  -default => $defaultPDB, -rows => $rowCount);                                  -default => $defaultPDB, -rows => $rowCount);
161      # Build a table from the PDB list and the submit row.      # Build a table from the PDB list and the submit row.
162      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),
# Line 171  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 195  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          PrintLine("Finding docking results for $pdbID.");          $self->PrintLine("Finding docking results for $pdbID.");
212          # Get a query that will return the docking results for this PDB.          # Get a query that will return the docking results for this PDB.
213          my $query= $sprout->Get(['DocksWith', 'Ligand'],          my $query= $sprout->Get(['DocksWith', 'Ligand'],
214                                  "DocksWith(from-link) = ?",                                  "DocksWith(from-link) = ? ORDER BY DocksWith(total-energy)",
215                                  [$pdbID]);                                  [$pdbID]);
216          # Write the column headers.          # Write the column headers.
217          $self->WriteColumnHeaders("ZINC ID", "Ligand", "Total Energy", "Electrostatic", "Van der Waals", "Tool");          $self->PrintLine("Processing results.");
         PrintLine("Processing results.");  
         my $rowCount = 0;  
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 @data = $record->Values(['Ligand(id)', 'Ligand(name)', 'DocksWith(electrostatic-energy)',              my ($id, $total, $electro, $vander, $tool) = $record->Values(['Ligand(id)',
222                                          'DocksWidth(vanderwaals-energy)', 'DocksWith(tool)']);                                                                            'DocksWith(total-energy)',
223              # Write it to the session file.                                                                            'DocksWith(electrostatic-energy)',
224              $self->WriteColumnData(@data);                                                                            'DocksWith(vanderwalls-energy)',
225                                                                              'DocksWith(tool)']);
226                # Format the energy results so they don't look so awful.
227                ($total, $electro, $vander) = map { sprintf('%.2f', $_) } ($total, $electro, $vander);
228                # Put the extra columns.
229                $rhelp->PutExtraColumns(energy => $total, electrostatic => $electro, vanderwaals => $vander,
230                                        tool => $tool);
231                # 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.
233                my $key = $retVal;
234                # Write everything to the session file.
235                $rhelp->PutData($key, $id, $record);
236              # See if we need to update the user.              # See if we need to update the user.
237              $rowCount++;              $retVal++;
238              if ($rowCount % 1000 == 0) {              if ($retVal % 1000 == 0) {
239                  PrintLine("$rowCount ligands processed.");                  $self->PrintLine("$retVal ligands processed.");
240              }              }
241          }          }
242            Trace("$retVal rows processed.") if T(3);
243          # Close the session file.          # Close the session file.
244          $self->CloseSession();          $self->CloseSession();
245      }      }
# Line 228  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 258  Line 261 
261      # Get the parameters.      # Get the parameters.
262      my ($self) = @_;      my ($self) = @_;
263      # Return the result.      # Return the result.
264      return "Show the PDB and gene relationships for a specified drug target analysis project.";      return "Show the docking results for a specific PDB.";
265  }  }
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 282  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;  
 }  
   
   
288  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3