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

View of /FigWebServices/SimBlockDisplay.cgi

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.1 - (download) (annotate)
Wed May 4 03:17:43 2005 UTC (14 years, 8 months ago) by parrello
Branch: MAIN
*** empty log message ***

#!/usr/bin/perl -w

    # Print the HTML header.
    print "CONTENT-TYPE: text/html\n\n";

=head1 Similarity Block Display

This script processes input from the C<SimBlockForm.cgi> script's web page and
produces lists of which genomes are in set 1 or set 2 and which blocks are in
set 1, set 2, or both genome sets. The user can select a particular block in
one of the columns and click the appropriate button to generate an alignment
display in the embedded frame below the block lists.

For debugging purposes, you can specify the B<Trace> parameter to
set the tracing level. You can also set the B<ShowMode> parameter to
C<1> to display a table of the parameters passed by the form. So,
for example,

C<< http://myseedurl/CGI/SimBlockDisplay.cgi?ShowMode=1 >>

will set the form action to display the form contents without processing
them, while

C<< http://myseedurl/CGI/SimBlockDisplay.cgi?Trace=3 >>

runs the standard processing script at a trace level of 3. Normally, only the
script itself and B<Tracer> tracing is active; however, you can activate other tracing modules
by appending them to the trace level. Thus,

C<< http://myseedurl/CGI/SimBlockDisplay.cgi?Trace=3%20SimBlocks%20DBObject >>

activates tracing for the similarity block module (C<SimBlocks.pm>) and the data
base object (C<DBObject.pm>).


use strict;
use CGI;
use Tracer;
use PageBuilder;
use SimBlocks;

# Get the CGI parameters.
my $query = new CGI;
my $traceLevel = $query->param("Trace");
if (!defined $traceLevel || length $traceLevel == 0) {
    $traceLevel = 0;
TSetup("$traceLevel Tracer", "QUEUE");
# Choose the output script based on the ShowMode parameter.
my $script = ($query->param('ShowMode') ? 'FormDisplay' : 'SimBlockPattern');
# Decide whether or not we need debugging fields.
my $traceFields = (Tracer::DebugMode() ? Tracer::GetFile("Html/DebugFragment.html") : "");
# Create the variable hash used to generate the web page. We start with the debug-related
# fields we've already computed.
my %varHash = ( script => $script, DebugData => $traceFields );
# Next we get the list of genomes in each set. These come from the radio
# buttons on the incoming form. Basically, we look for any option whose value
# is "set1" or "set2", and put it in the appropriate list. To make this process
# simpler, we set up a hash to contain the results.
my %sets = ( set1 => [], set2 => [] );
my @params = $query->param;
for my $param (@params) {
    my $parmValue = $query->param($param);
    if (exists $sets{$parmValue}) {
        push @{$sets{$parmValue}}, "$param";
# The genome IDs are converted to list options in the upper list boxes.
for my $setID (keys %sets) {
    # Get the list of values for this set.
    my $valueList = $sets{$setID};
    # Get its length.
    my $valueCount = @{$valueList};
    # Make sure the length is at least 2. Otherwise, the scrolling list becomes a
    # combo box.
    if ($valueCount < 2) {
        $valueCount = 2;
    # Build a multi-selection scrolling list big enough to show all the genome IDs.
    $varHash{"${setID}GenomeIDs"} = $query->scrolling_list("${setID}Genomes", $valueList,
                                                           undef, $valueCount, 1);
# Now we create the similarity block object.
my $simBlocks = SimBlocks->new();
# Get a comparison of the genome sets.
my %blocks;
($blocks{set1}, $blocks{set2}, $blocks{both}) = $simBlocks->CompareGenomes($sets{set1},
# Use the results to generate the scrolling lists for the similarity blocks. Our approach
# here is very much like what we did earlier for the genome IDs, but we put a maximum of
# 50 on the display size of each list.
for my $setID (keys %blocks) {
    # Get the list of blocks for this set.
    my $valueHash = $blocks{$setID};
    my @valueList = sort keys %{$valueHash};
    # Compute the desired list height.
    my $valueCount = @valueList;
    if ($valueCount > 50) {
        $valueCount = 50;
    } elsif ($valueCount < 2) {
        $valueCount = 2;
    # Build a single-selection scrolling list for this set of blocks.
    $varHash{"${setID}BlockIDs"} = $query->scrolling_list("${setID}Blocks",
                                                          \@valueList, undef,
# Flush the trace messages.
$varHash{TraceMessages} = QTrace('html');
# Generate the web page.
my $page = PageBuilder::Build("<Html/SimBlockDisplay.html", \%varHash, "Html");
print $page;


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3