[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.5, Tue Nov 28 21:50:59 2006 UTC revision 1.7, Fri May 11 06:30:48 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 45  Line 37 
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' => 'Known Toxin',                   'TX-K' => 'Toxin',
48                   'TX-B' => 'Putative Anti-Toxin Target',                   'TX-B' => 'Toxin',
49                   'SA-A' => 'Known Antigenic Protein',                   'SA-A' => 'Surface Associated',
50                   'SA-P' => 'Surface Associated',                   'SA-P' => 'Surface Associated',
51                   'SA-S' => 'Surface Associated',                   'SA-S' => 'Surface Associated',
52                   'SA'   => 'Surface Associated',                   'SA'   => 'Surface Associated',
53                   'SE-P' => 'Putative Secreted Protein',                   'SE-P' => 'Secreted Protein',
54                   'SE'   => 'Secreted Protein',                   'SE'   => 'Secreted Protein',
55                  );                  );
56    
# Line 99  Line 91 
91      return $retVal;      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 116  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], $_->[1] docking results" } @pdbData;
156      # Create the drop-down menu for scoring.      # Compute the number of rows to display in the selection list.
157      my $defaultScore = $cgi->param('score') || '1e-15';      my $rowCount = (scalar(@pdbStrings) < 20 ? scalar(@pdbStrings) : 20);
158      my $scoreMenu = $cgi->popup_menu(-name => 'score',      # Convert the PDB list into a selection list.
159                                       -values => ['1e-30', '1e-15', '1e-10', '1e-5', '1', '10'],      my $menu = $cgi->popup_menu(-name => 'PDB', -values => \@pdbStrings,
160                                       -default => $defaultScore);                                  -default => $defaultPDB, -rows => $rowCount);
161      # Build a table from the drop-down menu, the special options, 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)),
                 $cgi->Tr($cgi->th('Max Score'), $cgi->td($scoreMenu)),  
                 FeatureQuery::SpecialOptions($self),  
163                  $self->SubmitRow()                  $self->SubmitRow()
164                 );                 );
165      $retVal .= $self->MakeTable(\@rows);      $retVal .= $self->MakeTable(\@rows);
# Line 150  Line 177 
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
178  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
179  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.
180    This search does not return features, so it calls B<WriteColumnHeaders> and
181    B<WriteColumnData> instead of the handier B<PutFeature>
182    
183  =cut  =cut
184    
# Line 161  Line 190 
190      # Declare the return variable. If it remains undefined, the caller will      # Declare the return variable. If it remains undefined, the caller will
191      # know that an error occurred.      # know that an error occurred.
192      my $retVal;      my $retVal;
193      # Insure a project and score are selected.      # Insure a PDB is selected.
194      my $project = $cgi->param('project');      my $pdbID = $cgi->param('PDB');
195      my $score = $cgi->param('score');      if (! $pdbID) {
196      if (! $project) {          $self->SetMessage("No PDB specified.");
         $self->SetMessage("No project specified.");  
     } elsif (! $score) {  
         $self->SetMessage("No score specified.");  
197      } else {      } else {
198          # Initialize the session file.          # Initialize the session file.
199          $self->OpenSession();          $self->OpenSession();
200          # Initialize the result counter.          # Initialize the result counter.
201          $retVal = 0;          $retVal = 0;
202          # Get a query that will return the features for the project.          PrintLine("Finding docking results for $pdbID.");
203          my $query= $sprout->Get(['ContainsTopic', 'DrugTopic', 'ContainsAnalysisOf', 'PDB',          # Get a query that will return the docking results for this PDB.
204                                   'DescribesProteinForFeature', 'Feature'],          my $query= $sprout->Get(['DocksWith', 'Ligand'],
205                                  "ContainsTopic(from-link) = ? AND DescribesProteinForFeature(score) <= ?",                                  "DocksWith(from-link) = ?",
206                                  [$project, $score]);                                  [$pdbID]);
207          # Create a feature data object to manage our results.          # Write the column headers.
208          my $fd = FeatureData->new($self);          $self->WriteColumnHeaders("ZINC ID", "Ligand", "Total Energy", "Electrostatic", "Van der Waals", "Tool");
209            PrintLine("Processing results.");
210            my $rowCount = 0;
211          # Loop through the results.          # Loop through the results.
212          while (my $record = $query->Fetch()) {          while (my $record = $query->Fetch()) {
213              # Validate the PDB ID.              # Get the data for this row.
214              my ($pdb) = $record->Value('DescribesProteinForFeature(from-link)');              my @data = $record->Values(['Ligand(id)', 'Ligand(name)', 'DocksWith(electrostatic-energy)',
215              if ($pdb =~ /^pdb([^.]+)\./i) {                                          'DocksWidth(vanderwaals-energy)', 'DocksWith(tool)']);
216                  # Here we're okay, so we yank out the real PDB ID from the file title and              # Write it to the session file.
217                  # apply a link.              $self->WriteColumnData(@data);
218                  my $pdbID = $1;              # See if we need to update the user.
219                  my $pdbInfo = $cgi->a({href => "http://www.rcsb.org/pdb/explore.do?structureId=$pdbID",              $rowCount++;
220                                        title => "display this protein's page in the Protein Data Bank",              if ($rowCount % 1000 == 0) {
221                                        alt =>  "display this protein's page in the Protein Data Bank",                  PrintLine("$rowCount ligands processed.");
                                       target => "_blank"}, $pdbID);  
                 # Get the topic category. This explains why the PDB is interesting.  
                 my ($categoryCode) = $record->Value('DrugTopic(category)');  
                 my $category = $CodeTable{$categoryCode};  
                 # Extract the score.  
                 my ($score) = $record->Value('DescribesProteinForFeature(score)');  
                 # Store this feature in the data object.  
                 $fd->Store($record);  
                 # Add the PDB columns.  
                 $fd->AddExtraColumns('Free PDB' => $pdbInfo, 'Reason' => $category, 'Score' => $score);  
                 # Put it in the results list.  
                 $self->PutFeature($fd);  
                 $retVal++;  
             } else {  
                 # Here the PDB didn't have the format we expected.  
                 Confess("Invalid PDB ID \"$pdb\" found in database.")  
222              }              }
223          }          }
224          # Close the session file.          # Close the session file.
# Line 249  Line 261 
261      return "Show the PDB and gene relationships for a specified drug target analysis project.";      return "Show the PDB and gene relationships for a specified drug target analysis project.";
262  }  }
263    
264    =head3 SearchTitle
265    
266    C<< my $titleHtml = $shelp->SearchTitle(); >>
267    
268    Return the display title for this search. The display title appears above the search results.
269    If no result is returned, no title will be displayed. The result should be an html string
270    that can be legally put inside a block tag such as C<h3> or C<p>.
271    
272    =cut
273    
274    sub SearchTitle {
275        # Get the parameters.
276        my ($self) = @_;
277        # Compute the title. We extract the PDB ID from the query parameters.
278        my $cgi = $self->Q();
279        my $pdbID = $cgi->param('PDB');
280        my $retVal = "Docking Results for $pdbID";
281        # Return it.
282        return $retVal;
283    }
284    
285    =head3 DownloadFormatAvailable
286    
287    C<< my $okFlag = $shelp->DownloadFormatAvailable($format); >>
288    
289    This method returns TRUE if a specified download format is legal for this type of search
290    and FALSE otherwise. For any feature-based search, there is no need to override this
291    method.
292    
293    =over 4
294    
295    =item format
296    
297    Download format type code.
298    
299    =item RETURN
300    
301    Returns TRUE if the download format is legal for this search and FALSE otherwise.
302    
303    =back
304    
305    =cut
306    
307    sub DownloadFormatAvailable {
308        # Get the parameters.
309        my ($self, $format) = @_;
310        # Declare the return variable.
311        my $retVal = ($format eq 'tbl');
312        # Return the result.
313        return $retVal;
314    }
315    
316    
317  1;  1;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3