[Bio] / FigWebServices / targets.cgi Repository:
ViewVC logotype

Annotation of /FigWebServices/targets.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : parrello 1.1 #!/usr/bin/env /vol/drugtargets/FIGdisk/env/cee/bin/perl
2 :    
3 :    
4 :     BEGIN {
5 :     # Print the HTML header.
6 :     print "CONTENT-TYPE: text/html\n\n";
7 :     }
8 :     use strict;
9 :     use Tracer;
10 :     use CGI;
11 :     use Sprout;
12 :     use SHDrugSearch;
13 :    
14 :     my $odd = 1;
15 :     my @styles = ("even", "odd");
16 :     my $lkpdb ='http://www.rcsb.org/pdb/explore.do?structureId=';
17 :     my $fig = new FIG;
18 :    
19 :     my ($cgi, $varHash) = ScriptSetup();
20 :     #get the query paramaters
21 :     my $target = $cgi->param("target");
22 :     my $uctarget = ucfirst $target;
23 :    
24 :     eval {
25 :     my $org = $cgi->param("org");
26 :     # Set the descriptive variables. These change key words in the introductory
27 :     # text and page heading.
28 :     $varHash->{target} = $target;
29 :     $varHash->{uc_first_target} = ucfirst $target;
30 :     $varHash->{org} = $org;
31 :     #The script operates
32 :     &add_table_top($cgi, $varHash, $org);
33 :     if ($target){
34 :     &get_table($cgi, $varHash, "$target.txt");
35 :     }elsif($org){
36 :     &get_table($cgi, $varHash, $org);
37 :     }
38 :     $varHash->{result} .='</table>';
39 :     };
40 :    
41 :     # error messages
42 :     if ($@) {
43 :     my $errorMessage = $@;
44 :     Trace("Script Error: $errorMessage") if T(0);
45 :     }
46 :     ScriptFinish("targets_tmpl.php", $varHash);
47 :     #---Subs------#
48 :    
49 :     # This function adds the table header based on if we looking at a specific target category
50 :     sub add_table_top{
51 :     my ($cgi, $varHash, $org) = @_;
52 :     &add_words($cgi, $varHash, $org);
53 :     if($target){
54 :     $varHash->{result} .= ' <table width="90%" class="targets">
55 :     <tr class=odd><th>Organism</th><th>Functional Role</th><th>Candidacy<th>PDB</th></tr>';
56 :     }else{
57 :     $varHash->{result} .= '<table width="90%" class="targets">
58 :     <tr class=odd><th>Organism</th><th>Functional Role</th><th>Category</th><th>PDB</th></tr>';
59 :     }
60 :     }
61 :    
62 :     # This funtion adds the paragraphs needed to explain what we are looking at
63 :     # and how to navigate it
64 :     sub add_words{
65 :     my ($cgi, $varHash, $org) = @_;
66 :     if($org){
67 :     my $name= $fig->genus_species($org);
68 :     $varHash->{result} .= "<h1>$name targets</h1>";
69 :     if($target){
70 :     $varHash->{result} .= "<p>Cross section of<em> $name </em> and $uctarget Targets.</p>
71 :     <p>Candidacy column connects to literature source.</p>";
72 :     }else{
73 :     $varHash->{result} .= "<p>To narrow the table scope to a specific target category
74 :     click on a category within the larger table under the category column.</p>";
75 :     }
76 :     return;
77 :     }elsif($target){
78 :     $varHash->{result} .= "<h1> $uctarget Targets</h1>
79 :     <p>The proteins in these sets come from diverse sources
80 :     and the criteria for inclusion is intentionally broad.
81 :     Further curation, filtering and additions to these sets are planned.
82 :     Feedback to the NMPDR on these proteins is welcome.</p>
83 :     <p>To narrow the table scope to a specific organism
84 :     click on an organism in the larger table under the organism column</p>
85 :     <p>Candidacy column connects to literature source.</p>";
86 :     return;
87 :     }
88 :     }
89 :    
90 :     # This Sub funtions to open up the table and keep track of the index of what row we are on
91 :     sub get_table{
92 :     my($cgi, $varHash, $file)= @_;
93 :     Open(\*TABLE, "$FIG_Config::drug_directory/$file");
94 :     while (<TABLE>){
95 :     my @lines = split (/\r/,$_);
96 :     for my $i (0..scalar@lines-1) {
97 :     my @entry = split (/\t/,$lines[$i]);
98 :     # &print_row($entry[5], $entry[9], $entry[3], $entry[1], $i);
99 :     &get_best_pdb($cgi, $varHash, $i,$file);
100 :     }
101 :     }
102 :     }
103 :    
104 :    
105 :     # This Sub funtions to print the Table Row in the correct format.
106 :     sub print_column{
107 :     my($cgi, $varHash, $pdb, $color, $score,$peg, $func, $lit, $cat, $i) = @_ ;
108 :     my $genome = $peg;
109 :     $genome =~ s/fig\|//;
110 :     $genome =~ s/\.peg\.\d+//;
111 :     my $which = $fig->genus_species($genome);
112 :     $pdb =~ s/pdb//;
113 :     $pdb =~ s/\.ent//;
114 : parrello 1.2 $cat = changecat($cat);
115 : parrello 1.1 my $selfURL = $cgi->url(-relative => 1);
116 :     my $link = '../FIG/protein.cgi?new_framework=0&SPROUT=1&prot=';
117 :     my $org = $cgi->param('org');
118 :     Trace("Printing $color for $pdb.") if T(4);
119 :     if ($org && $target){
120 :     if ($peg =~ m/$org/){
121 :     $odd = 1 - $odd;
122 :     $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><em>$which</em><br>$peg</td>\n";
123 :     $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";
124 :     $varHash->{result} .= "<td><a href=\"$lit\">$cat</a></td>\n";
125 :     $varHash->{result} .= "<td color=\"$color\"><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";
126 :     }
127 :     }elsif($target){
128 :     $odd = 1 - $odd;
129 :     $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><a href=\"$selfURL?org=$genome&target=$target\"><em>$which</em></a><br>$peg</td>\n";
130 :     $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";
131 :     $varHash->{result} .= "<td><a href=\"$lit\">$cat</a></td>\n";
132 :     $varHash->{result} .= "<td color=\"$color\"><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";
133 :     }elsif($org){
134 :     $odd = 1 - $odd;
135 :     $varHash->{result} .= "<tr class=\"$styles[$odd]\"><td><em>$which</em><br>$peg</td>\n";
136 :     $varHash->{result} .= "<td>$func (<a href=\"$link$peg\">NMPDR</a>)</td>\n";
137 :     &get_attribute($cgi, $varHash, $peg, $genome);
138 :     $varHash->{result} .= "<td color=$color><a href=\"$lkpdb$pdb\">$pdb</a></td>\n";
139 :     }
140 :     }
141 :    
142 :     # This sub changes the Candidacy code to something meaningful.
143 :     sub changecat{
144 :     my($dog) = @_;
145 :     Trace("Selecting category for $dog.") if T(3);
146 :     my $cat = SHDrugSearch::GetCategory($dog);
147 :     return $cat;
148 :     }
149 :    
150 :     # This sub determines if a peg has an atribute
151 :     sub get_attribute{
152 :     my ($cgi, $varHash, $peg, $genome) = @_;
153 :     my %files = (drug => "drug.txt", toxin => "toxin.txt", vaccine => "vaccine.txt");
154 :     my $selfURL = $cgi->url(-relative => 1);
155 :     for my $key (keys %files) {
156 :     Open(\*DATA, "$FIG_Config::drug_directory/$files{$key}");
157 :     while (<DATA>){
158 :     my @lines = split (/\r/,$_);
159 :     foreach(@lines){
160 :     my @entry = split(/\t/,$_);
161 :     if ("$entry[5]" eq "$peg"){
162 :     my $title = ucfirst $key;
163 :     $varHash->{result} .= "<td><a href=$selfURL?org=$genome&target=$key>$title</a></td>\n";
164 :     return;
165 :     }
166 :     }
167 :     }
168 :     close(DATA);
169 :     }
170 :     $varHash->{result} .= "<td><a href=\"../content/contactus.php\">Suggest</a></td>\n";
171 :     return;
172 :     }
173 :    
174 :     #-- we wish to desplay only the best pdbs and those that are relavent
175 :     sub get_best_pdb{
176 :     my ($cgi, $varHash, $i, $file)= @_;
177 :     my @pdbresults =("1ah7","1dhn","1tfu"); # we define what pdb actually have been docked well.
178 :     Open(\*TABLE, "$FIG_Config::drug_directory/$file");
179 :     while (<TABLE>){
180 :     my @lines = split (/\r/,$_);
181 :     my @entry = split(/\t/,$lines[$i]);
182 :     if (T(4)) {
183 :     my $line = "Processing line\n";
184 :     for (my $i = 0; $i <= $#entry; $i++) {
185 :     $line .= "$i. $entry[$i]\n";
186 :     }
187 :     Trace($line);
188 :     }
189 :     Trace("Analyzing PDB $entry[11].") if T(4);
190 :     foreach (@pdbresults){ #look through the results we have
191 :     if ($entry[11] =~ m/$_/gi){ #ifwe have results for the free
192 :     &print_column($cgi, $varHash, $entry[11],'red', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
193 :     return;
194 :     }elsif($entry[14] =~ m/$_/gi){ #if we have resutls for the bound
195 :     &print_column($cgi, $varHash,$entry[14], 'red', $entry[16],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we wnat to display this
196 :     return;
197 :     }
198 :     }
199 :     if ($entry[13] eq "0"){ #if the free pdb is perfect
200 :     &print_column($cgi, $varHash, $entry[11], '', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
201 :     return;
202 :     }elsif($entry[16] eq '0'){ #if the bound pdb is perfect
203 :     &print_column($cgi, $varHash, $entry[14], '', $entry[16],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
204 :     return;
205 :     }elsif($entry[13] =~ /\d\.\d*E\-(\d+)/ ){ #if the eval is like 1.4E-45
206 :     if (15 < $1) { #and the exponant is less than 1.0E-15
207 :     if($entry[16] =~ /\d\.\d*E\-(\d+)/ ){ #but we should check if the bound is any better
208 :     if (15 < $1){ #and the xponant is less than 1.0-15 we need to do the comparison
209 :     my @free = split(/E\-/,$entry[13]);
210 :     my @bound = split(/E\-/,$entry[16]);
211 :     my $efree = $free[0] * 13 ** -$free[1];
212 :     my $ebound = $bound[0] * 13 ** -$bound[1];
213 :     if ($efree <= $ebound){ #if the free is less than the boutd
214 :     &print_column($cgi, $varHash, $entry[11], 'black', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
215 :     return;
216 :     }else{
217 :     &print_column($cgi, $varHash, $entry[14], 'green', $entry[16],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
218 :     return;
219 :     }
220 :     }else{ #the bound exponent wasn't less than 15
221 :     &print_column($cgi, $varHash, $entry[11], 'blue', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
222 :     return;
223 :     }
224 :     }else{ #the bound pdb didn't even have an exponant
225 :     &print_column($cgi, $varHash, $entry[11], 'yello', $entry[13],$entry[5], $entry[9], $entry[3], $entry[1], $i); #we want to display this
226 :     return; #this takes care the if free is good and bound is bad
227 :     }#a free pdb is no good becaus eval > 1e-15
228 :     }#free pdb was no good because eval > 1e-15
229 :     }elsif($entry[16] =~ /\d\.\d*E\-(\d+)/ ){ #we are now checking if the bound pdb is good
230 :     if (15 < $1) {
231 :     &print_column($cgi, $varHash, $entry[14], 'black', $entry[16],$entry[5], $entry[9], $entry[3], $entry[1], $i);
232 :     return;
233 :     }
234 :     }
235 :     }
236 :     Trace("No result printed for line $i in file $file.") if T(4);
237 :     }
238 :    
239 :    
240 :     # -error interupt--these subs will probably go when bruce sees them
241 :     sub err {
242 :     my ($msg) = @_;
243 :     $msg = "Error!" unless $msg;
244 :     print (&colored($msg, "CC0033"));
245 :     die "$msg\n";
246 :     }
247 :    
248 :     sub colored {
249 :     my ($text, $color) = @_;
250 :     return "<font color=$color>$text</font>";
251 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3