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

Annotation of /GBBergeyDB/get_cluster.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 :    
5 :     use Table;
6 :     use DBMaster;
7 :    
8 :     my $dbmaster = DBMaster->new('GBBergeyDB');
9 :     my $cgi = new CGI;
10 :    
11 :     my $cluster_number = $cgi->param('clid');
12 :     my $cluster = $dbmaster->STScluster->get_objects( { number => $cgi->param('clid') } )->[0];
13 :     my $genomes = $dbmaster->Genome->get_objects( { STScluster => $cluster } );
14 :    
15 :     my $content = "";
16 :     my $uid = $cgi->param('uid');
17 :    
18 :     my $dbmaster2 = DBMaster->new('FortyEight_WebApplication');
19 :     my $user_object = $dbmaster2->User->get_objects( { _id => $uid } )->[0];
20 :     my $user = $user_object->firstName . " " . $user_object->lastName;
21 :    
22 :     # check if a new not was added
23 :     if ($cgi->param('submitted')) {
24 :    
25 :     # get the parameters
26 :     my $description = $cgi->param('comment') || "";
27 :     my $timestamp = time();
28 :     my $passed_strain = $cgi->param('strain') || "";
29 :     my $strain;
30 :     unless ($passed_strain =~ /the species/) {
31 :     $strain = $dbmaster->Genome->get_objects( { name => $passed_strain } )->[0];
32 :     }
33 :     my $voting = $cgi->param('vote') || '';
34 :     if ($voting eq 'sequenced') {
35 :     $voting = 1;
36 :     } elsif ($voting eq 'not_sequenced') {
37 :     $voting = 2;
38 :     } else {
39 :     $voting = undef;
40 :     }
41 :     my $confidence = $cgi->param('confidence');
42 :     if ($confidence eq 'high') {
43 :     $confidence = 1;
44 :     } elsif ($confidence eq 'average') {
45 :     $confidence = 2;
46 :     } else {
47 :     $confidence = 3;
48 :     }
49 :    
50 :     # create the note object
51 :     $dbmaster->Note->create( { user => $user,
52 :     description => $description,
53 :     timestamp => time(),
54 :     voting => $voting,
55 :     confidence => $confidence,
56 :     Species => $strain->Species,
57 :     Strain => $strain } );
58 :     }
59 :    
60 :     # sort genomes
61 :     my @sorted_genomes = sort { $a->name cmp $b->name } @$genomes;
62 :    
63 :     # print cluster information
64 :     my $cluster_score = '-';
65 :     $content .= "<h2>Cluster " . $cluster->number . "</h2>";
66 : paczian 1.2 $content .= "<table><tr><td title='Similarity to closest Cluster'><b>% Similarity</b></td><td>" . $cluster->score . "</td></tr><tr><td title='highlighted in blue'><b>representative species</b></td><td style='border: 1px solid blue;'>" . $cluster->representative->Species->name . "</td></tr></table><br>";
67 : paczian 1.1
68 :     # print strain table
69 : paczian 1.2 $content .= "<table><tr><td><b>Species</b></td><td><b>#compl.</b></td><td><b>#in prog.</b></td></tr>";
70 : paczian 1.1 my $show_voting = 1;
71 :     foreach my $genome (@sorted_genomes) {
72 :    
73 :     # get sequencing counts
74 :     my $compl = scalar(@{$dbmaster->Genome->get_objects( { Species => $genome->Species, sequencingStatus => 'complete' } )});
75 :     my $in_prog = scalar(@{$dbmaster->Genome->get_objects( { Species => $genome->Species, sequencingStatus => 'incomplete' } )});
76 :     if (($compl > 0) || ($in_prog > 0)) {
77 :     $show_voting = 0;
78 :     }
79 :    
80 : paczian 1.2 # check for representative
81 :     my $highlight = "";
82 :     if ($genome->STScluster->representative->name eq $genome->name) {
83 :     $highlight = " style='border: 1px solid blue;'";
84 : paczian 1.1 }
85 :    
86 :     # create entry
87 : paczian 1.2 $content .= "<tr><td" . $highlight . "><span title='click for details' style='cursor: pointer;' onclick='window.open(\"get_notes.cgi?uid=$uid&spec=" . $genome->Species->name . "\", \"Species " . $genome->Species->name . "\", \"location=no,menu=no,width=850,height=700,status=no,toolbar=no,scrollbars=yes,resizable=yes\");'>" . $genome->name . "</span></td><td>" . $compl . "</td><td>" . $in_prog . "</td></tr>";
88 : paczian 1.1 }
89 :     $content .= "</table>";
90 :    
91 :     # print note-form
92 :     if ($show_voting) {
93 :     $content .= "<hr/>";
94 :     $content .= "<h2>Vote</h2>";
95 :     $content .= "<form action='get_cluster.cgi' method='get'>";
96 :     $content .= "<input type='hidden' name='submitted' value='1'>";
97 :    
98 :     if (scalar(@$genomes) > 1) {
99 :     $content .= "I vote for <select name='strain'>";
100 :     foreach my $genome (@sorted_genomes) {
101 :     $content .= "<option value='" . $genome->name . "'>" . $genome->name . "</option>";
102 :     }
103 :     $content .= "</select>";
104 :     }
105 :    
106 :     $content .= "<br/>to be <select name='vote'>";
107 :     $content .= "<option value='sequenced'>sequenced</option>";
108 :     $content .= "<option value='not sequenced'>not sequenced</option>";
109 :     $content .= "</select>";
110 :    
111 :     $content .= "<br/>My confidence about this vote is <select name='confidence'>";
112 :     $content .= "<option value='high'>high</option>";
113 :     $content .= "<option value='average' selected=selected>average</option>";
114 :     $content .= "<option value='low'>low</option>";
115 :     $content .= "</select>";
116 :    
117 :     $content .= "<br/><textarea name='comment' cols='50' rows='6'></textarea>";
118 :     $content .= "<br/><input type='submit' value='Add'>";
119 :     $content .= "<input type='hidden' name='uid' value='" . $cgi->param('uid') . "'>";
120 :     $content .= "</form>";
121 :     }
122 :     print $cgi->header();
123 :     print "<html><head><title>Cluster " . $cluster->number . "</title></head><body>";
124 :     print '<link rel="stylesheet" type="text/css" href="./Html/genomeselector.css">';
125 :     print "<div style='padding: 15px;'>";
126 :     print $content;
127 :     print "</div></body></html>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3