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

Annotation of /FigWebServices/SimBlockPattern.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download)

1 : parrello 1.1 #!/usr/bin/perl -w
2 : olson 1.3 #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 : parrello 1.1
20 :     BEGIN {
21 :     # Print the HTML header.
22 :     print "CONTENT-TYPE: text/html\n\n";
23 :     }
24 :    
25 :     =head1 Similarity Block Alignment Display
26 :    
27 :     This script generates a table displaying the contents of a similarity block in the
28 :     form of an alignment between the regions in the block. The basic idea is that
29 :     we get all the regions in the specified block and display the ones belonging to
30 :     genomes selected in the scrolling lists for the sets. The individual regions will
31 :     be shown as rows in a table. Each row will be created from a template fragment.
32 :     The base page uses a style sheet that has a special style called C<dna> for the
33 :     DNA display in the table row. The C<em> tag will be applied to the columns that
34 :     vary inside the block so that they are more easily detected. These columns are
35 :     identified by question marks in the block pattern found in the original block
36 :     record.
37 :    
38 :     For debugging purposes, you can specify the B<Trace> parameter to
39 :     set the tracing level. You can also set the B<ShowMode> parameter to
40 :     C<1> to display a table of the parameters passed by the form. So,
41 :     for example,
42 :    
43 :     C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3 >>
44 :    
45 :     runs the standard processing script at a trace level of 3. Normally, only the
46 :     script itself and B<Tracer> tracing is active; however, you can activate other tracing modules
47 :     by appending them to the trace level. Thus,
48 :    
49 :     C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3%20SimBlocks%20DBObject >>
50 :    
51 :     activates tracing for the similarity block module (C<SimBlocks.pm>) and the data
52 :     base object (C<DBObject.pm>).
53 :    
54 :     =cut
55 :    
56 :     use strict;
57 :     use CGI;
58 :     use Tracer;
59 :     use PageBuilder;
60 :     use SimBlocks;
61 :    
62 :     # Get the CGI parameters.
63 :     my $query = new CGI;
64 :     my $traceLevel = $query->param("Trace");
65 :     if (!defined $traceLevel || length $traceLevel == 0) {
66 :     $traceLevel = "0";
67 :     }
68 :     TSetup("$traceLevel Tracer", "QUEUE");
69 :    
70 :     # Our first task is to get the parameters. We need a list of the IDs of the selected
71 : parrello 1.2 # genomes. These lists will be found in the "set0Genomes" and "set1Genomes" parameters.
72 : parrello 1.1
73 : parrello 1.2 my @set0 = $query->param("set0Genomes");
74 :     my @set1 = $query->param("set1Genomes");
75 :     my @genomes = (@set0, @set1);
76 : parrello 1.1
77 :     # Next, we need to get the block ID. The block ID is going to be the value of the
78 : parrello 1.2 # "set0Blocks", "set1Blocks", or "bothBlocks" parameter, depending on whether the
79 :     # "set0Button", "set1Button", or "bothButton" parameter is present.
80 : parrello 1.1 my $blockID;
81 : parrello 1.2 for my $setID ('set0', 'both', 'set1') {
82 : parrello 1.1 my $thisBlockID = $query->param("${setID}Blocks");
83 :     if ($thisBlockID && $query->param("${setID}Button")) {
84 :     $blockID = $thisBlockID;
85 :     }
86 :     }
87 :     Trace("Block $blockID selected for genomes " . join ", ", @genomes) if T(2);
88 :     # Now we have all the information we need to produce the alignment. We need to
89 :     # create the similarity block object and start the web page.
90 :     my $simBlock = SimBlocks->new();
91 :     my $builder = PageBuilder::new("Html/SimBlockPattern.html", {}, "Html");
92 :     # Protect against errors.
93 :     eval {
94 :     # Next we need the template fragment for the rows.
95 :     my $rowFragment = Tracer::GetFile("Html/SimBlockPatternRow.html");
96 :     # Get the block from the similarity block database and extract its pattern.
97 : parrello 1.2 my $blockData = $simBlock->GetBlock($blockID);
98 : parrello 1.1 my ($pattern) = $blockData->Value('GroupBlock(pattern)');
99 :     # Get the regions for the block.
100 :     my %regions = $simBlock->GetRegions($blockID, \@genomes);
101 :     for my $region (sort keys %regions) {
102 :     my $dna = $regions{$region};
103 : parrello 1.2 # Get this region's set number.
104 :     my $setNumber = SimBlocks::SetNumber($region, \@set0, \@set1);
105 : parrello 1.1 # Mark the variant columns with EM tags.
106 :     $dna = SimBlocks::TagDNA($pattern, $dna, "<em>", "</em>");
107 :     # Create a table row for this region.
108 : parrello 1.2 my $row = PageBuilder::Build($rowFragment, { region => $region, dna => $dna,
109 :     setNumber => $setNumber }, "Html");
110 : parrello 1.1 print $row;
111 :     }
112 : parrello 1.2 # Now we need to create the snip list. The snip list is a column-oriented
113 :     # table (that is, each data item is in a separate column), so we we will
114 :     # build the rows in parallel and plug them into the HTML fragment. First
115 :     # we get the snip analysis.
116 :     my %snips = $simBlock->SnipScan($blockID, \@set0, \@set1);
117 :     # Extract the positions.
118 :     my @positions = (sort { $a <=> $b } keys %snips);
119 :     # Create lists for the set1 and set2 rows.
120 :     my @set0Data = ();
121 :     my @set1Data = ();
122 :     # Loop through the positions.
123 :     for my $position (@positions) {
124 :     my $setList = $snips{$position};
125 :     push @set0Data, $setList->[0];
126 :     push @set1Data, $setList->[1];
127 :     }
128 :     # Create the rows from the lists.
129 :     my $positionRow = join "</td><td>", @positions;
130 :     my $set0Row = join "</td><td>", @set0Data;
131 :     my $set1Row = join "</td><td>", @set1Data;
132 :     # Plug them into the fragment and write it out.
133 :     my $snipData = PageBuilder::Build("<Html/SimBlockSnipFragment.html",
134 :     { positionRow => $positionRow, set0Row => $set0Row,
135 :     set1Row => $set1Row }, "Html");
136 :     print $snipData;
137 : parrello 1.1 };
138 :     # Trace any error that occurred.
139 :     if ($@) {
140 :     Trace($@) if T(0);
141 :     }
142 :     # Write out any trace messages.
143 :     my $qtrace = QTrace("html");
144 :     print $qtrace;
145 :     # Finish the web page.
146 :     $builder->Finish();
147 :    
148 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3