[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.4, Wed Nov 15 22:34:50 2006 UTC revision 1.8, Thu May 17 23:43:57 2007 UTC
# Line 13  Line 13 
13    
14      our @ISA = qw(SearchHelper);      our @ISA = qw(SearchHelper);
15    
16  =head1 Drug Target Project Summary Feature Search Helper  =head1 Drug Target PDB Docking Results Search Helper
17    
18  =head2 Introduction  =head2 Introduction
19    
20  This search helper will display all the features that participated in a particular  This search helper will display all the docking results for a particular
21  drug target project. Each project represents a single study, generally related  PDB. Most search helpers return a list of features. This one returns
22  to a specified organism. The study finds PDBs that are good drug target  a list of ligands. As a result, it is structurally very different. In
23  candidates, and these are connected to the relevant B<DrugTargetProject> entity  particular, all the columns are returned as extras.
 instance in the database. From the PDB, we can get a list of the related  
 features, and these features are the ones we return in the search.  
24    
25  This search has the following extra parameters in addition to the ones  This search has the following extra parameters.
 produced by the B<SpecialOptions> method of the B<FeatureQuery> object.  
26    
27  =over 4  =over 4
28    
29  =item project  =item PDB
30    
31  ID of the drug target project to display.  ID of the PDB whose information is to be displayed.
   
 =item score  
   
 Maximum allowable score for a PDB/PEG match to be considered good  
 enough to display. The default is 1e-15.  
32    
33  =back  =back
34    
# Line 44  Line 36 
36    
37  # Table of drug topic category codes.  # Table of drug topic category codes.
38  my %CodeTable = (  my %CodeTable = (
39                   'ES'   => 'essential',                   'ES'   => 'Essential',
40                   'ES-X' => 'essential, determined by experiment',                   'ES-X' => 'Essential',
41                   'ES-L' => 'essential, from the literature',                   'ES-L' => 'Essential',
42                   'KA-T' => 'known Antibiotic target',                   'KA-T' => 'Antibiotic Target',
43                   'KA-I' => 'known Antibiotic Inhibitor',                   'KA-I' => 'Antibiotic Inhibitor',
44                   'VA'   => 'virulence associated',                   'VA'   => 'Virulence Associated',
45                   'VA-K' => 'known virulence associated',                   'VA-K' => 'Virulence Associated',
46                   'VA-P' => 'putative virulence assocated'                   'VA-P' => 'Virulence Assocated',
47                     'TX-K' => 'Toxin',
48                     'TX-B' => 'Toxin',
49                     'SA-A' => 'Surface Associated',
50                     'SA-P' => 'Surface Associated',
51                     'SA-S' => 'Surface Associated',
52                     'SA'   => 'Surface Associated',
53                     'SE-P' => 'Secreted Protein',
54                     'SE'   => 'Secreted Protein',
55                  );                  );
56    
57    =head3 GetCategory
58    
59    C<< my $description = SHDrugSearch::GetCategory($code); >>
60    
61    Return the description of the specified category code.
62    
63    =over 4
64    
65    =item code
66    
67    Category code to convert.
68    
69    =item RETURN
70    
71    Returns the description of the specified category code, as taken from the C<CodeTable> hash.
72    
73    =back
74    
75    =cut
76    
77    sub GetCategory {
78        # Get the parameters.
79        my ($code) = @_;
80        # Convert to upper case.
81        my $catCode = uc $code;
82        # Trim spaces.
83        $catCode =~ s/\s+//g;
84        # Extract it from the hash table.
85        my $retVal = $CodeTable{$catCode};
86        # Check for a not-found condition.
87        if (! $retVal) {
88            $retVal = "Unknown Code $catCode";
89        }
90        # Return the result.
91        return $retVal;
92    }
93    
94    =head3 PDBLink
95    
96    C<< my $pdbHtml = SHDrugSearch::PDBLink($cgi, $pdbID); >>
97    
98    This method converts a PDB ID to a hyperlink into the PDB web site.
99    
100    =over 4
101    
102    =item cgi
103    
104    CGI object to be used to create the HTML.
105    
106    =item pdbID
107    
108    ID of the PDB to be hyperlinked.
109    
110    =item RETURN
111    
112    Returns a hyperlinked PDB ID that points to the PDB's page on the RCSB web site.
113    
114    =back
115    
116    =cut
117    
118    sub PDBLink {
119        # Get the parameters.
120        my ($cgi, $pdbID) = @_;
121        # Compose the link.
122        my $retVal = $cgi->a({href => "http://www.rcsb.org/pdb/explore.do?structureId=$pdbID",
123                              title => "display this protein's page in the Protein Data Bank",
124                              alt =>  "display this protein's page in the Protein Data Bank",
125                              target => "_blank"}, $pdbID);
126    
127        # Return the result.
128        return $retVal;
129    }
130    
131  =head2 Virtual Methods  =head2 Virtual Methods
132    
133  =head3 Form  =head3 Form
# Line 71  Line 145 
145      my $cgi = $self->Q();      my $cgi = $self->Q();
146      my $sprout = $self->DB();      my $sprout = $self->DB();
147      # Start the form.      # Start the form.
148      my $retVal = $self->FormStart("Select Drug Target Project");      my $retVal = $self->FormStart("Select PDB");
149      # Get a list of all the projects.      # Get a list of all the PDBs with docking results.
150      my @projectNames = $sprout->GetFlat(['DrugProject'], "", [], 'DrugProject(id)');      my @pdbData = $sprout->GetAll(['PDB'], "PDB(docking-count) > 0 ORDER BY PDB(docking-count) DESC",
151      # See if there's already a project selected.                                    [], ['PDB(id)', 'PDB(docking-count)']);
152      my $defaultProject = $cgi->param('project');      # See if there's already a PDB selected.
153      # Convert the project list into a drop-down menu.      my $defaultPDB = $cgi->param('PDB');
154      my $menu = $cgi->popup_menu(-name => 'project', -values => \@projectNames,      # Create the PDB selection strings.
155                                  -default => $defaultProject);      my %pdbStrings = map { $_->[0] => "$_->[0], $_->[1] docking results" } @pdbData;
156      # Create the drop-down menu for scoring.      my @pdbNames = map { $_->[0] } @pdbData;
157      my $defaultScore = $cgi->param('score') || '1e-15';      # Compute the number of rows to display in the selection list.
158      my $scoreMenu = $cgi->popup_menu(-name => 'score',      my $rowCount = (scalar(@pdbNames) < 20 ? scalar(@pdbNames) : 20);
159                                       -values => ['1e-30', '1e-15', '1e-10', '1e-5', '1', '10'],      # Convert the PDB list into a selection list.
160                                       -default => $defaultScore);      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbNames,
161      # Build a table from the drop-down menu, the special options, and the submit row.                                  -labels => \%pdbStrings,
162                                    -default => $defaultPDB, -rows => $rowCount);
163        # Build a table from the PDB list and the submit row.
164      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),      my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),
                 $cgi->Tr($cgi->th('Max Score'), $cgi->td($scoreMenu)),  
                 FeatureQuery::SpecialOptions($self),  
165                  $self->SubmitRow()                  $self->SubmitRow()
166                 );                 );
167      $retVal .= $self->MakeTable(\@rows);      $retVal .= $self->MakeTable(\@rows);
# Line 105  Line 179 
179  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
180  returned. If the search parameters are invalid, a result count of C<undef> will be  returned. If the search parameters are invalid, a result count of C<undef> will be
181  returned and a result message will be stored in this object describing the problem.  returned and a result message will be stored in this object describing the problem.
182    This search does not return features, so it calls B<WriteColumnHeaders> and
183    B<WriteColumnData> instead of the handier B<PutFeature>
184    
185  =cut  =cut
186    
# Line 116  Line 192 
192      # Declare the return variable. If it remains undefined, the caller will      # Declare the return variable. If it remains undefined, the caller will
193      # know that an error occurred.      # know that an error occurred.
194      my $retVal;      my $retVal;
195      # Insure a project and score are selected.      # Insure a PDB is selected.
196      my $project = $cgi->param('project');      my $pdbID = $cgi->param('PDB');
197      my $score = $cgi->param('score');      if (! $pdbID) {
198      if (! $project) {          $self->SetMessage("No PDB specified.");
         $self->SetMessage("No project specified.");  
     } elsif (! $score) {  
         $self->SetMessage("No score specified.");  
199      } else {      } else {
200          # Initialize the session file.          # Initialize the session file.
201          $self->OpenSession();          $self->OpenSession();
202          # Initialize the result counter.          # Initialize the result counter.
203          $retVal = 0;          $retVal = 0;
204          # Get a query that will return the features for the project.          $self->PrintLine("Finding docking results for $pdbID.");
205          my $query= $sprout->Get(['ContainsTopic', 'DrugTopic', 'ContainsAnalysisOf', 'PDB',          # Get a query that will return the docking results for this PDB.
206                                   'DescribesProteinForFeature', 'Feature'],          my $query= $sprout->Get(['DocksWith', 'Ligand'],
207                                  "ContainsTopic(from-link) = ? AND DescribesProteinForFeature(score) <= ?",                                  "DocksWith(from-link) = ? ORDER BY DocksWith(total-energy)",
208                                  [$project, $score]);                                  [$pdbID]);
209          # Create a feature data object to manage our results.          # Write the column headers.
210          my $fd = FeatureData->new($self);          $self->WriteColumnHeaders("ZINC ID", "Total Energy", "Electrostatic", "Van der Waals", "Tool");
211            $self->PrintLine("Processing results.");
212          # Loop through the results.          # Loop through the results.
213          while (my $record = $query->Fetch()) {          while (my $record = $query->Fetch()) {
214              # Validate the PDB ID.              # Get the data for this row.
215              my ($pdb) = $record->Value('DescribesProteinForFeature(from-link)');              my ($id, $name, $total, $electro, $vander, $tool) = $record->Values(['Ligand(id)', 'Ligand(name)',
216              if ($pdb =~ /^pdb([^.]+)\./i) {                                                                                   'DocksWith(total-energy)',
217                  # Here we're okay, so we yank out the real PDB ID from the file title and                                                                                   'DocksWith(electrostatic-energy)',
218                  # apply a link.                                                                                   'DocksWith(vanderwalls-energy)',
219                  my $pdbID = $1;                                                                                   'DocksWith(tool)']);
220                  my $pdbInfo = $cgi->a({href => "http://www.rcsb.org/pdb/explore.do?structureId=$pdbID",              # Format the energy results so they don't look so awful.
221                                        title => "display this protein's page in the Protein Data Bank",              my @data = map { sprintf('%.2f', $_) } ($total, $electro, $vander);
222                                        alt =>  "display this protein's page in the Protein Data Bank",              # Create a tooltip for the ligand name.
223                                        target => "_blank"}, $pdbID);              my $linkedID = $cgi->a({ href => "http://blaster.docking.org/zinc/srchdbk.pl?zinc=$id;go=Query",
224                  # Get the topic category. This explains why the PDB is interesting.                                       title => $name }, $id);
225                  my ($categoryCode) = $record->Value('DrugTopic(category)');              # Finally, we must compute the sort key. We're getting the records in the correct order, so
226                  my $category = $CodeTable{$categoryCode};              # the sort key is the ordinal of this record, which we are keeping in $retVal.
227                  # Extract the score.              my $key = $retVal;
228                  my ($score) = $record->Value('DescribesProteinForFeature(score)');              # Write everything to the session file.
229                  # Store this feature in the data object.              $self->WriteColumnData($retVal, $id, $linkedID, @data, $tool);
230                  $fd->Store($record);              # See if we need to update the user.
                 # Add the PDB columns.  
                 $fd->AddExtraColumns('Free PDB' => $pdbInfo, 'Reason' => $category, 'Score' => $score);  
                 # Put it in the results list.  
                 $self->PutFeature($fd);  
231                  $retVal++;                  $retVal++;
232              } else {              if ($retVal % 1000 == 0) {
233                  # Here the PDB didn't have the format we expected.                  $self->PrintLine("$retVal ligands processed.");
                 Confess("Invalid PDB ID \"$pdb\" found in database.")  
234              }              }
235          }          }
236            Trace("$retVal rows processed.") if T(3);
237          # Close the session file.          # Close the session file.
238          $self->CloseSession();          $self->CloseSession();
239      }      }
# Line 201  Line 271 
271      # Get the parameters.      # Get the parameters.
272      my ($self) = @_;      my ($self) = @_;
273      # Return the result.      # Return the result.
274      return "Show the PDB and gene relationships for a specified drug target analysis project.";      return "Show the docking results for a specific PDB.";
275    }
276    
277    =head3 SearchTitle
278    
279    C<< my $titleHtml = $shelp->SearchTitle(); >>
280    
281    Return the display title for this search. The display title appears above the search results.
282    If no result is returned, no title will be displayed. The result should be an html string
283    that can be legally put inside a block tag such as C<h3> or C<p>.
284    
285    =cut
286    
287    sub SearchTitle {
288        # Get the parameters.
289        my ($self) = @_;
290        # Compute the title. We extract the PDB ID from the query parameters.
291        my $cgi = $self->Q();
292        my $pdbID = $cgi->param('PDB');
293        my $retVal = "Docking Results for $pdbID";
294        # Return it.
295        return $retVal;
296  }  }
297    
298    =head3 DownloadFormatAvailable
299    
300    C<< my $okFlag = $shelp->DownloadFormatAvailable($format); >>
301    
302    This method returns TRUE if a specified download format is legal for this type of search
303    and FALSE otherwise. For any feature-based search, there is no need to override this
304    method.
305    
306    =over 4
307    
308    =item format
309    
310    Download format type code.
311    
312    =item RETURN
313    
314    Returns TRUE if the download format is legal for this search and FALSE otherwise.
315    
316    =back
317    
318    =cut
319    
320    sub DownloadFormatAvailable {
321        # Get the parameters.
322        my ($self, $format) = @_;
323        # Declare the return variable.
324        my $retVal = ($format eq 'tbl');
325        # Return the result.
326        return $retVal;
327    }
328    
329    =head3 ColumnTitle
330    
331    C<< my $title = $shelp->ColumnTitle($colName); >>
332    
333    Return the column heading title to be used for the specified column name.
334    In this case, we just return the column name unmodified.
335    
336    =over 4
337    
338    =item colName
339    
340    Name of the desired column.
341    
342    =item RETURN
343    
344    Returns the title to be used as the column header for the named column.
345    
346    =back
347    
348    =cut
349    
350    sub ColumnTitle {
351        my ($self, $colName) = @_;
352        return $colName;
353    }
354    
355    
356  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3