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

Annotation of /FigWebServices/SimBlockDisplay.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     BEGIN {
4 :     # Print the HTML header.
5 :     print "CONTENT-TYPE: text/html\n\n";
6 :     }
7 :    
8 :     =head1 Similarity Block Display
9 :    
10 :     This script processes input from the C<SimBlockForm.cgi> script's web page and
11 :     produces lists of which genomes are in set 1 or set 2 and which blocks are in
12 :     set 1, set 2, or both genome sets. The user can select a particular block in
13 :     one of the columns and click the appropriate button to generate an alignment
14 :     display in the embedded frame below the block lists.
15 :    
16 :     For debugging purposes, you can specify the B<Trace> parameter to
17 :     set the tracing level. You can also set the B<ShowMode> parameter to
18 :     C<1> to display a table of the parameters passed by the form. So,
19 :     for example,
20 :    
21 :     C<< http://myseedurl/CGI/SimBlockDisplay.cgi?ShowMode=1 >>
22 :    
23 :     will set the form action to display the form contents without processing
24 :     them, while
25 :    
26 :     C<< http://myseedurl/CGI/SimBlockDisplay.cgi?Trace=3 >>
27 :    
28 :     runs the standard processing script at a trace level of 3. Normally, only the
29 :     script itself and B<Tracer> tracing is active; however, you can activate other tracing modules
30 :     by appending them to the trace level. Thus,
31 :    
32 :     C<< http://myseedurl/CGI/SimBlockDisplay.cgi?Trace=3%20SimBlocks%20DBObject >>
33 :    
34 :     activates tracing for the similarity block module (C<SimBlocks.pm>) and the data
35 :     base object (C<DBObject.pm>).
36 :    
37 :     =cut
38 :    
39 :     use strict;
40 :     use CGI;
41 :     use Tracer;
42 :     use PageBuilder;
43 :     use SimBlocks;
44 :    
45 :     # Get the CGI parameters.
46 :     my $query = new CGI;
47 :     my $traceLevel = $query->param("Trace");
48 :     if (!defined $traceLevel || length $traceLevel == 0) {
49 :     $traceLevel = 0;
50 :     }
51 :     TSetup("$traceLevel Tracer", "QUEUE");
52 :     # Choose the output script based on the ShowMode parameter.
53 :     my $script = ($query->param('ShowMode') ? 'FormDisplay' : 'SimBlockPattern');
54 :     # Decide whether or not we need debugging fields.
55 :     my $traceFields = (Tracer::DebugMode() ? Tracer::GetFile("Html/DebugFragment.html") : "");
56 :     # Create the variable hash used to generate the web page. We start with the debug-related
57 :     # fields we've already computed.
58 :     my %varHash = ( script => $script, DebugData => $traceFields );
59 :     # Next we get the list of genomes in each set. These come from the radio
60 :     # buttons on the incoming form. Basically, we look for any option whose value
61 :     # is "set1" or "set2", and put it in the appropriate list. To make this process
62 :     # simpler, we set up a hash to contain the results.
63 :     my %sets = ( set1 => [], set2 => [] );
64 :     my @params = $query->param;
65 :     for my $param (@params) {
66 :     my $parmValue = $query->param($param);
67 :     if (exists $sets{$parmValue}) {
68 :     push @{$sets{$parmValue}}, "$param";
69 :     }
70 :     }
71 :     # The genome IDs are converted to list options in the upper list boxes.
72 :     for my $setID (keys %sets) {
73 :     # Get the list of values for this set.
74 :     my $valueList = $sets{$setID};
75 :     # Get its length.
76 :     my $valueCount = @{$valueList};
77 :     # Make sure the length is at least 2. Otherwise, the scrolling list becomes a
78 :     # combo box.
79 :     if ($valueCount < 2) {
80 :     $valueCount = 2;
81 :     }
82 :     # Build a multi-selection scrolling list big enough to show all the genome IDs.
83 :     $varHash{"${setID}GenomeIDs"} = $query->scrolling_list("${setID}Genomes", $valueList,
84 :     undef, $valueCount, 1);
85 :     }
86 :     # Now we create the similarity block object.
87 :     my $simBlocks = SimBlocks->new();
88 :     # Get a comparison of the genome sets.
89 :     my %blocks;
90 :     ($blocks{set1}, $blocks{set2}, $blocks{both}) = $simBlocks->CompareGenomes($sets{set1},
91 :     $sets{set2});
92 :     # Use the results to generate the scrolling lists for the similarity blocks. Our approach
93 :     # here is very much like what we did earlier for the genome IDs, but we put a maximum of
94 :     # 50 on the display size of each list.
95 :     for my $setID (keys %blocks) {
96 :     # Get the list of blocks for this set.
97 :     my $valueHash = $blocks{$setID};
98 :     my @valueList = sort keys %{$valueHash};
99 :     # Compute the desired list height.
100 :     my $valueCount = @valueList;
101 :     if ($valueCount > 50) {
102 :     $valueCount = 50;
103 :     } elsif ($valueCount < 2) {
104 :     $valueCount = 2;
105 :     }
106 :     # Build a single-selection scrolling list for this set of blocks.
107 :     $varHash{"${setID}BlockIDs"} = $query->scrolling_list("${setID}Blocks",
108 :     \@valueList, undef,
109 :     $valueCount);
110 :     }
111 :     # Flush the trace messages.
112 :     $varHash{TraceMessages} = QTrace('html');
113 :     # Generate the web page.
114 :     my $page = PageBuilder::Build("<Html/SimBlockDisplay.html", \%varHash, "Html");
115 :     print $page;
116 :    
117 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3