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

View of /GBBergeyDB/get_cluster.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (annotate)
Mon Mar 5 18:50:41 2007 UTC (12 years, 9 months ago) by paczian
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +7 -15 lines
*** empty log message ***

use strict;
use warnings;
use CGI;

use Table;
use DBMaster;

my $dbmaster = DBMaster->new('GBBergeyDB');
my $cgi = new CGI;

my $cluster_number = $cgi->param('clid');
my $cluster = $dbmaster->STScluster->get_objects( { number => $cgi->param('clid') } )->[0];
my $genomes = $dbmaster->Genome->get_objects( { STScluster => $cluster } );

my $content = "";
my $uid = $cgi->param('uid');

my $dbmaster2 = DBMaster->new('FortyEight_WebApplication');
my $user_object = $dbmaster2->User->get_objects( { _id => $uid } )->[0];
my $user = $user_object->firstName . " " . $user_object->lastName;

# check if a new not was added
if ($cgi->param('submitted')) {

    # get the parameters
    my $description = $cgi->param('comment') || "";
    my $timestamp = time();
    my $passed_strain = $cgi->param('strain') || "";
    my $strain;
    unless ($passed_strain =~ /the species/) {
	$strain = $dbmaster->Genome->get_objects( { name => $passed_strain } )->[0];
    }
    my $voting = $cgi->param('vote') || '';
    if ($voting eq 'sequenced') {
	$voting = 1;
    } elsif ($voting eq 'not_sequenced') {
	$voting = 2;
    } else {
	$voting = undef;
    }
    my $confidence = $cgi->param('confidence');
    if ($confidence eq 'high') {
	$confidence = 1;
    } elsif ($confidence eq 'average') {
	$confidence = 2;
    } else {
	$confidence = 3;
    }

    # create the note object
    $dbmaster->Note->create( { user        => $user,
			       description => $description,
			       timestamp   => time(),
			       voting      => $voting,
			       confidence  => $confidence,
			       Species     => $strain->Species,
			       Strain      => $strain } );
}

# sort genomes
my @sorted_genomes = sort { $a->name cmp $b->name } @$genomes;

# print cluster information
my $cluster_score = '-';
$content .= "<h2>Cluster " . $cluster->number . "</h2>";
$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>";

# print strain table
$content .= "<table><tr><td><b>Species</b></td><td><b>#compl.</b></td><td><b>#in prog.</b></td></tr>";
my $show_voting = 1;
foreach my $genome (@sorted_genomes) {

    # get sequencing counts
    my $compl = scalar(@{$dbmaster->Genome->get_objects( { Species => $genome->Species, sequencingStatus => 'complete' } )});
    my $in_prog = scalar(@{$dbmaster->Genome->get_objects( { Species => $genome->Species, sequencingStatus => 'incomplete' } )});
    if (($compl > 0) || ($in_prog > 0)) {
	$show_voting = 0;
    }

    # check for representative
    my $highlight = "";
    if ($genome->STScluster->representative->name eq $genome->name) {
	$highlight = " style='border: 1px solid blue;'";
    }

    # create entry
    $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>";
}
$content .= "</table>";

# print note-form
if ($show_voting) {
    $content .= "<hr/>";
    $content .= "<h2>Vote</h2>";
    $content .= "<form action='get_cluster.cgi' method='get'>";
    $content .= "<input type='hidden' name='submitted' value='1'>";

    if (scalar(@$genomes) > 1) {
	$content .= "I vote for <select name='strain'>";
	foreach my $genome (@sorted_genomes) {
	    $content .= "<option value='" . $genome->name . "'>" . $genome->name . "</option>";
	}
	$content .= "</select>";
    }

    $content .= "<br/>to be <select name='vote'>";
    $content .= "<option value='sequenced'>sequenced</option>";
    $content .= "<option value='not sequenced'>not sequenced</option>";
    $content .= "</select>";

    $content .= "<br/>My confidence about this vote is <select name='confidence'>";
    $content .= "<option value='high'>high</option>";
    $content .= "<option value='average' selected=selected>average</option>";
    $content .= "<option value='low'>low</option>";
    $content .= "</select>";

    $content .= "<br/><textarea name='comment' cols='50' rows='6'></textarea>";
    $content .= "<br/><input type='submit' value='Add'>";
    $content .= "<input type='hidden' name='uid' value='" . $cgi->param('uid') . "'>";
    $content .= "</form>";
}
print $cgi->header();
print "<html><head><title>Cluster " . $cluster->number . "</title></head><body>";
print '<link rel="stylesheet" type="text/css" href="./Html/genomeselector.css">';
print "<div style='padding: 15px;'>";
print $content;
print "</div></body></html>";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3