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

Annotation of /FigWebServices/SimBlockPattern.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (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 Alignment Display
9 :    
10 :     This script generates a table displaying the contents of a similarity block in the
11 :     form of an alignment between the regions in the block. The basic idea is that
12 :     we get all the regions in the specified block and display the ones belonging to
13 :     genomes selected in the scrolling lists for the sets. The individual regions will
14 :     be shown as rows in a table. Each row will be created from a template fragment.
15 :     The base page uses a style sheet that has a special style called C<dna> for the
16 :     DNA display in the table row. The C<em> tag will be applied to the columns that
17 :     vary inside the block so that they are more easily detected. These columns are
18 :     identified by question marks in the block pattern found in the original block
19 :     record.
20 :    
21 :     For debugging purposes, you can specify the B<Trace> parameter to
22 :     set the tracing level. You can also set the B<ShowMode> parameter to
23 :     C<1> to display a table of the parameters passed by the form. So,
24 :     for example,
25 :    
26 :     C<< http://myseedurl/CGI/SimBlockPattern.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/SimBlockPattern.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 :    
53 :     # Our first task is to get the parameters. We need a list of the IDs of the selected
54 : parrello 1.2 # genomes. These lists will be found in the "set0Genomes" and "set1Genomes" parameters.
55 : parrello 1.1
56 : parrello 1.2 my @set0 = $query->param("set0Genomes");
57 :     my @set1 = $query->param("set1Genomes");
58 :     my @genomes = (@set0, @set1);
59 : parrello 1.1
60 :     # Next, we need to get the block ID. The block ID is going to be the value of the
61 : parrello 1.2 # "set0Blocks", "set1Blocks", or "bothBlocks" parameter, depending on whether the
62 :     # "set0Button", "set1Button", or "bothButton" parameter is present.
63 : parrello 1.1 my $blockID;
64 : parrello 1.2 for my $setID ('set0', 'both', 'set1') {
65 : parrello 1.1 my $thisBlockID = $query->param("${setID}Blocks");
66 :     if ($thisBlockID && $query->param("${setID}Button")) {
67 :     $blockID = $thisBlockID;
68 :     }
69 :     }
70 :     Trace("Block $blockID selected for genomes " . join ", ", @genomes) if T(2);
71 :     # Now we have all the information we need to produce the alignment. We need to
72 :     # create the similarity block object and start the web page.
73 :     my $simBlock = SimBlocks->new();
74 :     my $builder = PageBuilder::new("Html/SimBlockPattern.html", {}, "Html");
75 :     # Protect against errors.
76 :     eval {
77 :     # Next we need the template fragment for the rows.
78 :     my $rowFragment = Tracer::GetFile("Html/SimBlockPatternRow.html");
79 :     # Get the block from the similarity block database and extract its pattern.
80 : parrello 1.2 my $blockData = $simBlock->GetBlock($blockID);
81 : parrello 1.1 my ($pattern) = $blockData->Value('GroupBlock(pattern)');
82 :     # Get the regions for the block.
83 :     my %regions = $simBlock->GetRegions($blockID, \@genomes);
84 :     for my $region (sort keys %regions) {
85 :     my $dna = $regions{$region};
86 : parrello 1.2 # Get this region's set number.
87 :     my $setNumber = SimBlocks::SetNumber($region, \@set0, \@set1);
88 : parrello 1.1 # Mark the variant columns with EM tags.
89 :     $dna = SimBlocks::TagDNA($pattern, $dna, "<em>", "</em>");
90 :     # Create a table row for this region.
91 : parrello 1.2 my $row = PageBuilder::Build($rowFragment, { region => $region, dna => $dna,
92 :     setNumber => $setNumber }, "Html");
93 : parrello 1.1 print $row;
94 :     }
95 : parrello 1.2 # Now we need to create the snip list. The snip list is a column-oriented
96 :     # table (that is, each data item is in a separate column), so we we will
97 :     # build the rows in parallel and plug them into the HTML fragment. First
98 :     # we get the snip analysis.
99 :     my %snips = $simBlock->SnipScan($blockID, \@set0, \@set1);
100 :     # Extract the positions.
101 :     my @positions = (sort { $a <=> $b } keys %snips);
102 :     # Create lists for the set1 and set2 rows.
103 :     my @set0Data = ();
104 :     my @set1Data = ();
105 :     # Loop through the positions.
106 :     for my $position (@positions) {
107 :     my $setList = $snips{$position};
108 :     push @set0Data, $setList->[0];
109 :     push @set1Data, $setList->[1];
110 :     }
111 :     # Create the rows from the lists.
112 :     my $positionRow = join "</td><td>", @positions;
113 :     my $set0Row = join "</td><td>", @set0Data;
114 :     my $set1Row = join "</td><td>", @set1Data;
115 :     # Plug them into the fragment and write it out.
116 :     my $snipData = PageBuilder::Build("<Html/SimBlockSnipFragment.html",
117 :     { positionRow => $positionRow, set0Row => $set0Row,
118 :     set1Row => $set1Row }, "Html");
119 :     print $snipData;
120 : parrello 1.1 };
121 :     # Trace any error that occurred.
122 :     if ($@) {
123 :     Trace($@) if T(0);
124 :     }
125 :     # Write out any trace messages.
126 :     my $qtrace = QTrace("html");
127 :     print $qtrace;
128 :     # Finish the web page.
129 :     $builder->Finish();
130 :    
131 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3