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

Annotation of /Sprout/SHDrugSearch.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     package SHDrugSearch;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :     use SearchHelper;
8 :     use CGI;
9 :     use HTML;
10 :     use Sprout;
11 :     use FeatureData;
12 :     use FeatureQuery;
13 :    
14 :     our @ISA = qw(SearchHelper);
15 :    
16 :     =head1 Drug Target Project Summary Feature Search Helper
17 :    
18 :     =head2 Introduction
19 :    
20 :     This search helper will display all the features that participated in a particular
21 :     drug target project. Each project represents a single study, generally related
22 :     to a specified organism. The study finds PDBs that are good drug target
23 :     candidates, and these are connected to the relevant B<DrugTargetProject> entity
24 :     instance in the database. From the PDB, we can get a list of the related
25 :     features, and these features are the ones we return in the search.
26 :    
27 :     This search has the following extra parameters in addition to the ones
28 :     produced by the B<SpecialOptions> method of the B<FeatureQuery> object.
29 :    
30 :     =over 4
31 :    
32 :     =item project
33 :    
34 :     ID of the drug target project to display.
35 :    
36 : parrello 1.3 =item score
37 :    
38 :     Maximum allowable score for a PDB/PEG match to be considered good
39 :     enough to display. The default is 1e-15.
40 :    
41 : parrello 1.1 =back
42 :    
43 : parrello 1.2 =cut
44 :    
45 :     # Table of drug topic category codes.
46 :     my %CodeTable = (
47 : parrello 1.5 'ES' => 'Essential',
48 :     'ES-X' => 'Essential, determined by experiment',
49 :     'ES-L' => 'Essential, from the literature',
50 :     'KA-T' => 'Known Antibiotic Target',
51 :     'KA-I' => 'Known Antibiotic Inhibitor',
52 :     'VA' => 'Virulence Associated',
53 :     'VA-K' => 'Known Virulence Associated',
54 :     'VA-P' => 'Putative Virulence Assocated',
55 :     'TX-K' => 'Known Toxin',
56 :     'TX-B' => 'Putative Anti-Toxin Target',
57 :     'SA-A' => 'Known Antigenic Protein',
58 :     'SA-P' => 'Surface Associated',
59 :     'SA-S' => 'Surface Associated',
60 :     'SA' => 'Surface Associated',
61 :     'SE-P' => 'Putative Secreted Protein',
62 :     'SE' => 'Secreted Protein',
63 : parrello 1.2 );
64 :    
65 : parrello 1.5 =head3 GetCategory
66 :    
67 :     C<< my $description = SHDrugSearch::GetCategory($code); >>
68 :    
69 :     Return the description of the specified category code.
70 :    
71 :     =over 4
72 :    
73 :     =item code
74 :    
75 :     Category code to convert.
76 :    
77 :     =item RETURN
78 :    
79 :     Returns the description of the specified category code, as taken from the C<CodeTable> hash.
80 :    
81 :     =back
82 :    
83 :     =cut
84 :    
85 :     sub GetCategory {
86 :     # Get the parameters.
87 :     my ($code) = @_;
88 :     # Convert to upper case.
89 :     my $catCode = uc $code;
90 :     # Trim spaces.
91 :     $catCode =~ s/\s+//g;
92 :     # Extract it from the hash table.
93 :     my $retVal = $CodeTable{$catCode};
94 :     # Check for a not-found condition.
95 :     if (! $retVal) {
96 :     $retVal = "Unknown Code $catCode";
97 :     }
98 :     # Return the result.
99 :     return $retVal;
100 :     }
101 :    
102 : parrello 1.1 =head2 Virtual Methods
103 :    
104 :     =head3 Form
105 :    
106 : parrello 1.3 C<< my $html = $shelp->Form(); >>
107 : parrello 1.1
108 :     Generate the HTML for a form to request a new search.
109 :    
110 :     =cut
111 :    
112 :     sub Form {
113 :     # Get the parameters.
114 :     my ($self) = @_;
115 :     # Get the CGI and sprout objects.
116 :     my $cgi = $self->Q();
117 :     my $sprout = $self->DB();
118 :     # Start the form.
119 :     my $retVal = $self->FormStart("Select Drug Target Project");
120 :     # Get a list of all the projects.
121 :     my @projectNames = $sprout->GetFlat(['DrugProject'], "", [], 'DrugProject(id)');
122 :     # See if there's already a project selected.
123 :     my $defaultProject = $cgi->param('project');
124 :     # Convert the project list into a drop-down menu.
125 :     my $menu = $cgi->popup_menu(-name => 'project', -values => \@projectNames,
126 :     -default => $defaultProject);
127 : parrello 1.3 # Create the drop-down menu for scoring.
128 :     my $defaultScore = $cgi->param('score') || '1e-15';
129 :     my $scoreMenu = $cgi->popup_menu(-name => 'score',
130 :     -values => ['1e-30', '1e-15', '1e-10', '1e-5', '1', '10'],
131 :     -default => $defaultScore);
132 : parrello 1.1 # Build a table from the drop-down menu, the special options, and the submit row.
133 :     my @rows = ($cgi->Tr($cgi->th('Project'), $cgi->td($menu)),
134 : parrello 1.3 $cgi->Tr($cgi->th('Max Score'), $cgi->td($scoreMenu)),
135 :     FeatureQuery::SpecialOptions($self),
136 :     $self->SubmitRow()
137 :     );
138 : parrello 1.1 $retVal .= $self->MakeTable(\@rows);
139 :     # Close the form.
140 :     $retVal .= $self->FormEnd();
141 :     # Return the result.
142 :     return $retVal;
143 :     }
144 :    
145 :     =head3 Find
146 :    
147 :     C<< my $resultCount = $shelp->Find(); >>
148 :    
149 :     Conduct a search based on the current CGI query parameters. The search results will
150 :     be written to the session cache file and the number of results will be
151 :     returned. If the search parameters are invalid, a result count of C<undef> will be
152 :     returned and a result message will be stored in this object describing the problem.
153 :    
154 :     =cut
155 :    
156 :     sub Find {
157 :     my ($self) = @_;
158 :     # Get the CGI and Sprout objects.
159 :     my $cgi = $self->Q();
160 :     my $sprout = $self->DB();
161 :     # Declare the return variable. If it remains undefined, the caller will
162 :     # know that an error occurred.
163 :     my $retVal;
164 : parrello 1.3 # Insure a project and score are selected.
165 : parrello 1.1 my $project = $cgi->param('project');
166 : parrello 1.3 my $score = $cgi->param('score');
167 : parrello 1.1 if (! $project) {
168 :     $self->SetMessage("No project specified.");
169 : parrello 1.3 } elsif (! $score) {
170 :     $self->SetMessage("No score specified.");
171 : parrello 1.1 } else {
172 :     # Initialize the session file.
173 :     $self->OpenSession();
174 :     # Initialize the result counter.
175 :     $retVal = 0;
176 :     # Get a query that will return the features for the project.
177 : parrello 1.2 my $query= $sprout->Get(['ContainsTopic', 'DrugTopic', 'ContainsAnalysisOf', 'PDB',
178 : parrello 1.1 'DescribesProteinForFeature', 'Feature'],
179 : parrello 1.3 "ContainsTopic(from-link) = ? AND DescribesProteinForFeature(score) <= ?",
180 :     [$project, $score]);
181 : parrello 1.1 # Create a feature data object to manage our results.
182 :     my $fd = FeatureData->new($self);
183 :     # Loop through the results.
184 :     while (my $record = $query->Fetch()) {
185 :     # Validate the PDB ID.
186 :     my ($pdb) = $record->Value('DescribesProteinForFeature(from-link)');
187 :     if ($pdb =~ /^pdb([^.]+)\./i) {
188 :     # Here we're okay, so we yank out the real PDB ID from the file title and
189 :     # apply a link.
190 :     my $pdbID = $1;
191 :     my $pdbInfo = $cgi->a({href => "http://www.rcsb.org/pdb/explore.do?structureId=$pdbID",
192 :     title => "display this protein's page in the Protein Data Bank",
193 :     alt => "display this protein's page in the Protein Data Bank",
194 :     target => "_blank"}, $pdbID);
195 : parrello 1.2 # Get the topic category. This explains why the PDB is interesting.
196 :     my ($categoryCode) = $record->Value('DrugTopic(category)');
197 :     my $category = $CodeTable{$categoryCode};
198 : parrello 1.3 # Extract the score.
199 :     my ($score) = $record->Value('DescribesProteinForFeature(score)');
200 : parrello 1.1 # Store this feature in the data object.
201 :     $fd->Store($record);
202 :     # Add the PDB columns.
203 : parrello 1.3 $fd->AddExtraColumns('Free PDB' => $pdbInfo, 'Reason' => $category, 'Score' => $score);
204 : parrello 1.1 # Put it in the results list.
205 :     $self->PutFeature($fd);
206 :     $retVal++;
207 :     } else {
208 :     # Here the PDB didn't have the format we expected.
209 :     Confess("Invalid PDB ID \"$pdb\" found in database.")
210 :     }
211 :     }
212 :     # Close the session file.
213 :     $self->CloseSession();
214 :     }
215 :     # Return the result count.
216 :     return $retVal;
217 :     }
218 :    
219 :     =head3 DefaultFeatureColumns
220 :    
221 :     C<< my @cols = $shelp->DefaultFeatureColumns(); >>
222 :    
223 :     This method returns a list of the descriptors for the columns to be
224 :     displayed by this search, overriding the standard column set.
225 :    
226 :     =cut
227 :    
228 :     sub DefaultFeatureColumns {
229 :     # Get the parameters.
230 :     my ($self) = @_;
231 :     # Return the result.
232 :     return qw(orgName function protlink);
233 :     }
234 :    
235 :     =head3 Description
236 :    
237 :     C<< my $htmlText = $shelp->Description(); >>
238 :    
239 :     Return a description of this search. The description is used for the table of contents
240 :     on the main search tools page. It may contain HTML, but it should be character-level,
241 :     not block-level, since the description is going to appear in a list.
242 :    
243 :     =cut
244 :    
245 :     sub Description {
246 :     # Get the parameters.
247 :     my ($self) = @_;
248 :     # Return the result.
249 : parrello 1.4 return "Show the PDB and gene relationships for a specified drug target analysis project.";
250 : parrello 1.1 }
251 :    
252 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3