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

Annotation of /GBBergeyDB/get_notes.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : paczian 1.1 use strict;
2 :     use warnings;
3 :     use CGI;
4 :    
5 :     use Table;
6 :     use DBMaster;
7 :    
8 :     my $dbmaster = DBMaster->new('GBBergeyDB');
9 :     my $cgi = new CGI;
10 :    
11 :     my $spec_name = $cgi->param('spec');
12 :     my $species = $dbmaster->Species->get_objects({ name => $spec_name })->[0];
13 :     my $genomes = $dbmaster->Genome->get_objects( { Species => $species } );
14 :    
15 :     my $content = "";
16 :    
17 :     my $dbmaster2 = DBMaster->new('FortyEight_WebApplication');
18 :     my $user_object = $dbmaster2->User->get_objects( { _id => $cgi->param('uid') } )->[0];
19 :     my $user = $user_object->firstName . " " . $user_object->lastName;
20 :    
21 :     # check if a new not was added
22 :     if ($cgi->param('submitted')) {
23 :    
24 :     # get the parameters
25 :     my $description = $cgi->param('comment') || "";
26 :     my $timestamp = time();
27 :     my $passed_strain = $cgi->param('strain') || "";
28 :     my $strain;
29 :     unless ($passed_strain =~ /the species/) {
30 :     $strain = $dbmaster->Genome->get_objects( { name => $passed_strain } )->[0];
31 :     }
32 :    
33 :     # create the note object
34 :     $dbmaster->Note->create( { user => $user,
35 :     description => $description,
36 :     timestamp => time(),
37 :     Species => $species,
38 :     Strain => $strain } );
39 :     }
40 :    
41 :     # check for ncbi link
42 :     my $ncbi_link = "";
43 :     if ($species->taxid) {
44 :     $ncbi_link = " <a href='http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=" . $species->taxid . "' target=_blank>(NCBI)</a>";
45 :     }
46 :    
47 :     # check for bacterio link
48 :     my $bacterio_link = "";
49 :     if ($species->getBacterioLink) {
50 :     $bacterio_link = " <a href='" . $species->getBacterioLink . "' target=_blank>LPSN</a>";
51 :     }
52 :    
53 :     # print Species information
54 :     $content .= "<h2>Species: " . $species->name . "</h2>";
55 :    
56 :     my $genus = $species->Genus;
57 :     my $family = $genus->Family;
58 :     my $order = $family->GOrder;
59 :     my $class = $order->Class;
60 :     my $phyla = $class->Phyla;
61 :     my $domain = $phyla->Domain;
62 :    
63 :     $content .= "<table>";
64 :     $content .= "<tr><td><b>Bergey Taxonomy</b></td><td>" . $domain->name . "; " .$phyla->name . "; " . $class->name . "; " . $order->name . "; " . $family->name . "; " . $genus->name . "</td></tr>";
65 :     $content .= "</table>";
66 :    
67 :     # print list of strains
68 :     $content .= "<table><tr><td rowspan='" . scalar(@$genomes) . "' style='vertical-align: top;font-weight: bold;'>Strains</td>";
69 :     my $first = 1;
70 :     my $i = 1;
71 :     foreach my $genome (@$genomes) {
72 :     unless ($first) {
73 :     $content .= "<tr>";
74 :     } else {
75 :     $first = 0;
76 :     }
77 :    
78 :     # check for gold link
79 :     my $gold_link = "";
80 :     if ($genome->goldstamp) {
81 :     $gold_link = $genome->goldstamp;
82 :     $gold_link =~ s/\s\(.*\)//;
83 :     $gold_link = " <a href='http://genomesonline.org/GOLD_CARDS/" . $gold_link . ".html' target=_blank>(GOLD)</a>";
84 :     }
85 :    
86 :     # check for ncbi link
87 :     $ncbi_link = "";
88 :     if ($genome->taxid) {
89 :     $ncbi_link = " <a href='http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=" . $genome->taxid . "' target=_blank>(NCBI)</a>";
90 :     }
91 :    
92 :     # check for 16s
93 :     my $sixTeenS = "</td>";
94 :     if ($genome->sixTeenS) {
95 :     $sixTeenS = $genome->sixTeenS;
96 :     $sixTeenS =~ s/(.{50})/$1\<br\>/g;
97 :     $sixTeenS = " <input type='button' value='16S' onclick='document.getElementById(\"sixteens_" . $i . "\").className=\"showme\";'></td><td class='hideme' id='sixteens_" . $i . "'><pre>" . $sixTeenS . "</pre><input type='button' value='hide' onclick='document.getElementById(\"sixteens_" . $i . "\").className=\"hideme\";'></td>";
98 :     }
99 :    
100 :     # create entry
101 :     $content .= "<td>" . $genome->name . $ncbi_link . $gold_link . $sixTeenS . "</tr>";
102 :     $i++;
103 :     }
104 :     $content .= "</table>";
105 :    
106 :     # print note-form
107 :     $content .= "<hr/>";
108 :     $content .= "<h2>Add your comment</h2>";
109 :     $content .= "<form action='get_notes.cgi' method='get'>";
110 :     $content .= "<input type='hidden' name='spec' value='" . $spec_name . "'>";
111 :     $content .= "<input type='hidden' name='submitted' value='1'>";
112 :    
113 :     if (scalar(@$genomes) > 1) {
114 :     $content .= "This note refers to <select name='strain'><option value='species'>the species <i>" . $spec_name . "</i></option>";
115 :     foreach my $genome (@$genomes) {
116 :     $content .= "<option value='" . $genome->name . "'>strain <i>" . $genome->name . "</i></option>";
117 :     }
118 :     $content .= "</select>";
119 :     }
120 :    
121 :     # $content .= "<br/>I vote for this species to be <select name='vote'>";
122 :     # $content .= "<option value='no_vote'>- no opinion -</option>";
123 :     # $content .= "<option value='top_100'>in the top 100</option>";
124 :     # $content .= "<option value='top_200'>in the top 200</option>";
125 :     # $content .= "<option value='top_300'>in the top 300</option>";
126 :     # $content .= "<option value='not_in_list'>not sequenced</option>";
127 :     # $content .= "</select>";
128 :    
129 :     # $content .= "<br/>My confidence about this vote is <select name='confidence'>";
130 :     # $content .= "<option value='high'>high</option>";
131 :     # $content .= "<option value='average' selected=selected>average</option>";
132 :     # $content .= "<option value='low'>low</option>";
133 :     # $content .= "</select>";
134 :    
135 :     $content .= "<br/><textarea name='comment' cols='50' rows='6'></textarea>";
136 :     $content .= "<br/><input type='submit' value='Add'>";
137 :     $content .= "<input type='hidden' name='uid' value='" . $cgi->param('uid') . "'>";
138 :     $content .= "</form>";
139 :    
140 :     $content .= "<hr/><h2>Current Notes</h2>";
141 :     my $notes = $dbmaster->Note->get_objects( { Species => $species } );
142 :     if (scalar(@$notes)) {
143 :     foreach my $note (@$notes) {
144 :    
145 :     # get time of note
146 :     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($note->timestamp);
147 :     my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
148 :     my $time = "$hour:$min";
149 :     $time =~ s/\:(\d)$/\:0$1/;
150 :     my $date = "$abbr[$mon] $mday $time";
151 :    
152 :     # contruct note headline
153 :     $content .= "<b>" . $date . " " . $note->user . ":</b><br/>";
154 :    
155 :     # check for reference to strain
156 :     if ($note->Strain) {
157 :     $content .= "<b>Referred Strain:</b> " . $note->Strain->name . "<br/>";
158 :     }
159 :    
160 :     # check for voting
161 :     if ($note->voting) {
162 :    
163 :     # check confidence
164 :     my $confidence;
165 :     if ($note->confidence == 1) {
166 :     $confidence = " high";
167 :     } elsif ($note->confidence == 2) {
168 :     $confidence = "n average";
169 :     } else {
170 :     $confidence = " low";
171 :     }
172 :    
173 :     # check voting
174 :     my $voting;
175 :     if ($note->voting == 1) {
176 :     $voting = "be in the top 100 to be sequenced.";
177 :     } elsif ($note->voting == 2) {
178 :     $voting = "be in the top 200 to be sequenced.";
179 :     } elsif ($note->voting == 3) {
180 :     $voting = "be in the top 300 to be sequenced.";
181 :     } else {
182 :     $voting = "not be sequenced.";
183 :     }
184 :    
185 :     # construct voting sentence
186 :     $content .= "<b>Vote:</b><br/>I have a" . $confidence . " confidence that this species should " . $voting . "<br/>";
187 :     }
188 :    
189 :     # print description
190 :     $content .= "<b>Note:</b><br/><div style='width: 300px;'>" . $note->description . "</div><br/>";
191 :     }
192 :     } else {
193 :     $content .= "There are currently no notes for this species.";
194 :     }
195 :    
196 :     print $cgi->header();
197 :     print "<html><head><title>" . $species->name . "</title></head><body>";
198 :     print '<link rel="stylesheet" type="text/css" href="./Html/genomeselector.css">';
199 :     print "<div style='padding: 15px;'>";
200 :     print $content;
201 :     print "</div></body></html>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3