[Bio] / GBBergeyDB / get_notes.cgi Repository:
ViewVC logotype

Annotation of /GBBergeyDB/get_notes.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download)

1 : paczian 1.1 use strict;
2 :     use warnings;
3 :     use CGI;
4 : paczian 1.2 use LWP::Simple;
5 : paczian 1.1
6 :     use Table;
7 :     use DBMaster;
8 :    
9 :     my $dbmaster = DBMaster->new('GBBergeyDB');
10 :     my $cgi = new CGI;
11 :    
12 :     my $spec_name = $cgi->param('spec');
13 :     my $species = $dbmaster->Species->get_objects({ name => $spec_name })->[0];
14 :     my $genomes = $dbmaster->Genome->get_objects( { Species => $species } );
15 :    
16 : paczian 1.2 my $content = "<script type='text/javascript' src='./Html/WAC_PopupTooltip.js'></script><link rel='stylesheet' type='text/css' href='./Html/genomeselector.css'>";
17 : paczian 1.1
18 :     my $dbmaster2 = DBMaster->new('FortyEight_WebApplication');
19 : paczian 1.2 my $uid = $cgi->param('uid');
20 : paczian 1.1 my $user_object = $dbmaster2->User->get_objects( { _id => $cgi->param('uid') } )->[0];
21 :     my $user = $user_object->firstName . " " . $user_object->lastName;
22 :    
23 :     # check if a new not was added
24 :     if ($cgi->param('submitted')) {
25 :    
26 :     # get the parameters
27 :     my $description = $cgi->param('comment') || "";
28 :     my $timestamp = time();
29 :     my $passed_strain = $cgi->param('strain') || "";
30 :     my $strain;
31 :     unless ($passed_strain =~ /the species/) {
32 :     $strain = $dbmaster->Genome->get_objects( { name => $passed_strain } )->[0];
33 :     }
34 :    
35 :     # create the note object
36 :     $dbmaster->Note->create( { user => $user,
37 :     description => $description,
38 :     timestamp => time(),
39 :     Species => $species,
40 :     Strain => $strain } );
41 :     }
42 :    
43 :     # check for ncbi link
44 :     my $ncbi_link = "";
45 : paczian 1.2 my $lineage = "";
46 : paczian 1.1 if ($species->taxid) {
47 : paczian 1.2 $ncbi_link = " <a href='http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=" . $species->taxid . "' target=_blank>" . $species->taxid . "</a>";
48 :    
49 :     # get ncbi lineage
50 :     my $url="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=taxonomy&report=sgml&id=" . $species->taxid;
51 :     my $ncbi_tax_page = get($url);
52 :     if ($ncbi_tax_page =~ /\&lt\;Lineage\&gt\;cellular organisms; (.*)\&lt\;\/Lineage\&gt\;/) {
53 :     $lineage = $1;
54 :     }
55 : paczian 1.1 }
56 :    
57 :     # check for bacterio link
58 :     my $bacterio_link = "";
59 :     if ($species->getBacterioLink) {
60 :     $bacterio_link = " <a href='" . $species->getBacterioLink . "' target=_blank>LPSN</a>";
61 :     }
62 :    
63 : paczian 1.2 # check for DMSZ link
64 :     my $dsmz_link = "-";
65 :     if ($species->getDSMZLink) {
66 :    
67 :     # check if link is valid
68 :     my $page = get($species->getDSMZLink);
69 :     if ($page) {
70 :     $dsmz_link = "<a href='" . $species->getDSMZLink . "' target=_blank>DMSZ</a>";
71 :     }
72 :     }
73 :    
74 :     # check for CCUG link
75 :     my $ccug_link = "-";
76 :     if ($species->getCCUGLink) {
77 :    
78 :     # check if link is valid
79 :     my $page = get($species->getCCUGLink);
80 :     unless ($page =~ /No record found in ALX with supplied URL/) {
81 :     $ccug_link = "<a href='" . $species->getCCUGLink . "' target=_blank>CCUG</a>";
82 :     }
83 :     }
84 :    
85 : paczian 1.1 # print Species information
86 :     $content .= "<h2>Species: " . $species->name . "</h2>";
87 :    
88 : paczian 1.2 # check if this is just an alias
89 :     if (($species->ScientificSpecies) && (ref($species->ScientificSpecies))) {
90 :     my $ssname = $species->ScientificSpecies->name;
91 :     $content .= "<b>The new name of this species is <span title='click for details' style='color: blue; cursor: pointer;' onclick='window.open(\"get_notes.cgi?uid=$uid&spec=" . $ssname . "\", \"Species " . $ssname . "\", \"location=no,menu=no,width=850,height=700,status=no,toolbar=no,scrollbars=yes,resizable=yes\");'>" . $ssname . "</span></b><br><br>";
92 :     }
93 :    
94 : paczian 1.1 my $genus = $species->Genus;
95 :     my $family = $genus->Family;
96 :     my $order = $family->GOrder;
97 :     my $class = $order->Class;
98 :     my $phyla = $class->Phyla;
99 :     my $domain = $phyla->Domain;
100 :    
101 : paczian 1.2 # create species info table
102 : paczian 1.1 $content .= "<table>";
103 : paczian 1.2 $content .= "<tr><td><b><a href='http://www.bergeys.org/' target=_blank>Bergey Taxonomy</a></b></td><td>" . $domain->name . "; " .$phyla->name . "; " . $class->name . "; " . $order->name . "; " . $family->name . "; " . $genus->name . "</td></tr>";
104 :     $content .= "<tr><td><b><a href='http://www.ncbi.nlm.nih.gov/Taxonomy/' target=_blank>NCBI Taxonomy</a></b></td><td>" . $lineage . "</td></tr>";
105 :     $content .= "<tr><td><b><a href='http://www.ncbi.nlm.nih.gov/Taxonomy/' target=_blank>NCBI Taxonomy ID</a></b></td><td>" . $ncbi_link . "</td></tr>";
106 :     $content .= "<tr><td><b><a href='http://www.bacterio.cict.fr/' target=_blank>French LPSN</a></b></td><td>" . $bacterio_link . "</td></tr>";
107 :     $content .= "<tr><td><b><a href='http://www.dsmz.de/' target=_blank>DMSZ</a></b></td><td>" . $dsmz_link . "</td></tr>";
108 :     $content .= "<tr><td><b><a href='http://www.ccug.se/' target=_blank>CCUG</a></b></td><td>" . $ccug_link . "</td></tr>";
109 : paczian 1.1 $content .= "</table>";
110 :    
111 :     # print list of strains
112 : paczian 1.2 $content .= "<hr><b>Strains (Type Strain highlighted in blue)</b><br><br>";
113 : paczian 1.1 my $first = 1;
114 :     my $i = 1;
115 :     foreach my $genome (@$genomes) {
116 : paczian 1.2
117 :     # create popup
118 :     my $link_list = "<table>";
119 :    
120 :     # check for ncbi link
121 :     $ncbi_link = "";
122 :     if ($genome->taxid) {
123 :     $ncbi_link = " <a href='http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=" . $genome->taxid . "' target=_blank>(NCBI)</a>";
124 :     $link_list .= "<tr><td><b>NCBI Taxonomy ID</b></td><td>" . $genome->taxid . "</td></tr>";
125 : paczian 1.1 }
126 :    
127 :     # check for gold link
128 :     my $gold_link = "";
129 :     if ($genome->goldstamp) {
130 :     $gold_link = $genome->goldstamp;
131 :     $gold_link =~ s/\s\(.*\)//;
132 : paczian 1.2 $link_list .= "<tr><td><b>GOLD</b></td><td>" . $gold_link . "</td></tr>";
133 : paczian 1.1 $gold_link = " <a href='http://genomesonline.org/GOLD_CARDS/" . $gold_link . ".html' target=_blank>(GOLD)</a>";
134 :     }
135 :    
136 : paczian 1.2 # check for DMSZ link
137 :     $dsmz_link = "";
138 :     if ($genome->getDSMZLink) {
139 :     $dsmz_link = " <a href='" . $genome->getDSMZLink . "' target=_blank>(DMSZ)</a>";
140 :     my $dsmz_id = $genome->getDSMZLink;
141 :     $dsmz_id =~ s/(.*)\/strain\.(.*)\.html/$2/;
142 :     $link_list .= "<tr><td><b>DSMZ</b></td><td>" . $dsmz_id . "</td></tr>";
143 :     }
144 :    
145 :     # check for CCUG link
146 :     $ccug_link = "";
147 :     if ($genome->getCCUGLink) {
148 :     $ccug_link = " <a href='" . $genome->getCCUGLink . "' target=_blank>(CCUG)</a>";
149 :     my $ccug_id = $genome->getCCUGLink;
150 :     $ccug_id =~ s/(.*)\=(.*)/$2/;
151 :     $link_list .= "<tr><td><b>CCUG</b></td><td>" . $ccug_id . "</td></tr>";
152 :     }
153 :    
154 :     # check for ATCC link
155 :     my $atcc_link = "";
156 :     if ($genome->getATCCLink) {
157 :     $atcc_link = " <a href='" . $genome->getATCCLink . "' target=_blank>(ATCC)</a>";
158 :     my $atcc_id = $genome->getATCCLink;
159 :     $atcc_id =~ s/(.*)\=(.*)/$2/;
160 :     $link_list .= "<tr><td><b>ATCC</b></td><td>" . $atcc_id . "</td></tr>";
161 : paczian 1.1 }
162 :    
163 :     # check for 16s
164 :     my $sixTeenS = "</td>";
165 :     if ($genome->sixTeenS) {
166 :     $sixTeenS = $genome->sixTeenS;
167 :     $sixTeenS =~ s/(.{50})/$1\<br\>/g;
168 : paczian 1.2 $sixTeenS = " <input type='button' value='16S' onclick='var w = window.open(\"\", \"\", \"location=no,menu=no,width=450,height=450,status=no,toolbar=no,scrollbars=yes,resizable=yes\");w.document.open();w.document.write(\"<pre>>" . $genome->name . "<br/>" . $sixTeenS . "</pre>\");w.document.close();'></td>";
169 : paczian 1.1 }
170 :    
171 : paczian 1.2 $link_list .= "</table>";
172 :    
173 :     # check for typestrain
174 :     my $highlight = " style='cursor: default; padding-left: 3px; padding-right: 2px; '";
175 :     if ($genome->typeStrain) {
176 :     $highlight = " style='border: 1px solid blue; padding-left: 2px; padding-right: 2px; cursor: default;'";
177 :     }
178 :    
179 :     # write popup string
180 :     my $popup = " onmouseover=\"javascript:if(!this.tooltip) this.tooltip=new Popup_Tooltip(this, 'Reference IDs', '" . $link_list . "', '', '', '#466d94', '#ffffff'); this.tooltip.addHandler(); return false;\"";
181 :    
182 : paczian 1.1 # create entry
183 : paczian 1.2 $content .= "<span" . $popup . $highlight. ">" . $genome->name . "</span>" . $ncbi_link . $gold_link . $dsmz_link . $ccug_link . $atcc_link . $sixTeenS . "<br/>";
184 : paczian 1.1 $i++;
185 :     }
186 :    
187 :     # print note-form
188 :     $content .= "<hr/>";
189 :     $content .= "<h2>Add your comment</h2>";
190 :     $content .= "<form action='get_notes.cgi' method='get'>";
191 :     $content .= "<input type='hidden' name='spec' value='" . $spec_name . "'>";
192 :     $content .= "<input type='hidden' name='submitted' value='1'>";
193 :    
194 :     if (scalar(@$genomes) > 1) {
195 :     $content .= "This note refers to <select name='strain'><option value='species'>the species <i>" . $spec_name . "</i></option>";
196 :     foreach my $genome (@$genomes) {
197 :     $content .= "<option value='" . $genome->name . "'>strain <i>" . $genome->name . "</i></option>";
198 :     }
199 :     $content .= "</select>";
200 :     }
201 :    
202 :     # $content .= "<br/>I vote for this species to be <select name='vote'>";
203 :     # $content .= "<option value='no_vote'>- no opinion -</option>";
204 :     # $content .= "<option value='top_100'>in the top 100</option>";
205 :     # $content .= "<option value='top_200'>in the top 200</option>";
206 :     # $content .= "<option value='top_300'>in the top 300</option>";
207 :     # $content .= "<option value='not_in_list'>not sequenced</option>";
208 :     # $content .= "</select>";
209 :    
210 :     # $content .= "<br/>My confidence about this vote is <select name='confidence'>";
211 :     # $content .= "<option value='high'>high</option>";
212 :     # $content .= "<option value='average' selected=selected>average</option>";
213 :     # $content .= "<option value='low'>low</option>";
214 :     # $content .= "</select>";
215 :    
216 :     $content .= "<br/><textarea name='comment' cols='50' rows='6'></textarea>";
217 :     $content .= "<br/><input type='submit' value='Add'>";
218 :     $content .= "<input type='hidden' name='uid' value='" . $cgi->param('uid') . "'>";
219 :     $content .= "</form>";
220 :    
221 :     $content .= "<hr/><h2>Current Notes</h2>";
222 :     my $notes = $dbmaster->Note->get_objects( { Species => $species } );
223 :     if (scalar(@$notes)) {
224 :     foreach my $note (@$notes) {
225 :    
226 :     # get time of note
227 :     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($note->timestamp);
228 :     my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
229 :     my $time = "$hour:$min";
230 :     $time =~ s/\:(\d)$/\:0$1/;
231 :     my $date = "$abbr[$mon] $mday $time";
232 :    
233 :     # contruct note headline
234 :     $content .= "<b>" . $date . " " . $note->user . ":</b><br/>";
235 :    
236 :     # check for reference to strain
237 :     if ($note->Strain) {
238 :     $content .= "<b>Referred Strain:</b> " . $note->Strain->name . "<br/>";
239 :     }
240 :    
241 :     # check for voting
242 :     if ($note->voting) {
243 :    
244 :     # check confidence
245 :     my $confidence;
246 :     if ($note->confidence == 1) {
247 :     $confidence = " high";
248 :     } elsif ($note->confidence == 2) {
249 :     $confidence = "n average";
250 :     } else {
251 :     $confidence = " low";
252 :     }
253 :    
254 :     # check voting
255 :     my $voting;
256 :     if ($note->voting == 1) {
257 :     $voting = "be in the top 100 to be sequenced.";
258 :     } elsif ($note->voting == 2) {
259 :     $voting = "be in the top 200 to be sequenced.";
260 :     } elsif ($note->voting == 3) {
261 :     $voting = "be in the top 300 to be sequenced.";
262 :     } else {
263 :     $voting = "not be sequenced.";
264 :     }
265 :    
266 :     # construct voting sentence
267 :     $content .= "<b>Vote:</b><br/>I have a" . $confidence . " confidence that this species should " . $voting . "<br/>";
268 :     }
269 :    
270 :     # print description
271 :     $content .= "<b>Note:</b><br/><div style='width: 300px;'>" . $note->description . "</div><br/>";
272 :     }
273 :     } else {
274 :     $content .= "There are currently no notes for this species.";
275 :     }
276 :    
277 :     print $cgi->header();
278 :     print "<html><head><title>" . $species->name . "</title></head><body>";
279 :     print '<link rel="stylesheet" type="text/css" href="./Html/genomeselector.css">';
280 :     print "<div style='padding: 15px;'>";
281 :     print $content;
282 :     print "</div></body></html>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3