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

Annotation of /FigWebServices/SimBlockPattern.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (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 : parrello 1.4 #
8 : olson 1.3 # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 : parrello 1.4 # Public License.
11 : olson 1.3 #
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 : parrello 1.4 set the tracing level. So, for example,
40 : parrello 1.1
41 :     C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3 >>
42 :    
43 :     runs the standard processing script at a trace level of 3. Normally, only the
44 :     script itself and B<Tracer> tracing is active; however, you can activate other tracing modules
45 :     by appending them to the trace level. Thus,
46 :    
47 :     C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3%20SimBlocks%20DBObject >>
48 :    
49 :     activates tracing for the similarity block module (C<SimBlocks.pm>) and the data
50 :     base object (C<DBObject.pm>).
51 :    
52 :     =cut
53 :    
54 :     use strict;
55 :     use CGI;
56 :     use Tracer;
57 :     use PageBuilder;
58 :     use SimBlocks;
59 :    
60 : parrello 1.4 # Get the CGI parameters and set up the variable hash.
61 :     my ($query, $varHash) = ScriptSetup();
62 :     # Do this next part safely.
63 :     eval {
64 :     # Our first task is to get the parameters. We need a list of the IDs of the selected
65 :     # genomes. These lists will be found in the "set0Genomes" and "set1Genomes" parameters.
66 :    
67 :     my @set0 = $query->param("set0Genomes");
68 :     my @set1 = $query->param("set1Genomes");
69 :     my @genomes = (@set0, @set1);
70 :    
71 :     # Next, we need to get the block ID. The block ID is going to be the value of the
72 :     # "set0Blocks", "set1Blocks", or "bothBlocks" parameter, depending on whether the
73 :     # "set0Button", "set1Button", or "bothButton" parameter is present.
74 :     my $blockID;
75 :     for my $setID ('set0', 'both', 'set1') {
76 :     my $thisBlockID = $query->param("${setID}Blocks");
77 :     if ($thisBlockID && $query->param("${setID}Button")) {
78 :     $blockID = $thisBlockID;
79 :     }
80 : parrello 1.1 }
81 : parrello 1.4 Trace("Block $blockID selected for genomes " . join ", ", @genomes) if T(2);
82 :     # Now we have all the information we need to produce the alignment. We need to
83 :     # create the similarity block object and start the big block in the middle of
84 :     # the web page.
85 :     my $simBlock = SimBlocks->new();
86 :     my $webData = "";
87 : parrello 1.1 # Next we need the template fragment for the rows.
88 :     my $rowFragment = Tracer::GetFile("Html/SimBlockPatternRow.html");
89 :     # Get the block from the similarity block database and extract its pattern.
90 : parrello 1.2 my $blockData = $simBlock->GetBlock($blockID);
91 : parrello 1.1 my ($pattern) = $blockData->Value('GroupBlock(pattern)');
92 :     # Get the regions for the block.
93 :     my %regions = $simBlock->GetRegions($blockID, \@genomes);
94 :     for my $region (sort keys %regions) {
95 :     my $dna = $regions{$region};
96 : parrello 1.2 # Get this region's set number.
97 :     my $setNumber = SimBlocks::SetNumber($region, \@set0, \@set1);
98 : parrello 1.1 # Mark the variant columns with EM tags.
99 :     $dna = SimBlocks::TagDNA($pattern, $dna, "<em>", "</em>");
100 :     # Create a table row for this region.
101 : parrello 1.2 my $row = PageBuilder::Build($rowFragment, { region => $region, dna => $dna,
102 :     setNumber => $setNumber }, "Html");
103 : parrello 1.4 $webData .= $row;
104 : parrello 1.1 }
105 : parrello 1.2 # Now we need to create the snip list. The snip list is a column-oriented
106 :     # table (that is, each data item is in a separate column), so we we will
107 :     # build the rows in parallel and plug them into the HTML fragment. First
108 :     # we get the snip analysis.
109 :     my %snips = $simBlock->SnipScan($blockID, \@set0, \@set1);
110 :     # Extract the positions.
111 :     my @positions = (sort { $a <=> $b } keys %snips);
112 :     # Create lists for the set1 and set2 rows.
113 :     my @set0Data = ();
114 :     my @set1Data = ();
115 :     # Loop through the positions.
116 :     for my $position (@positions) {
117 :     my $setList = $snips{$position};
118 :     push @set0Data, $setList->[0];
119 :     push @set1Data, $setList->[1];
120 :     }
121 :     # Create the rows from the lists.
122 :     my $positionRow = join "</td><td>", @positions;
123 :     my $set0Row = join "</td><td>", @set0Data;
124 :     my $set1Row = join "</td><td>", @set1Data;
125 :     # Plug them into the fragment and write it out.
126 :     my $snipData = PageBuilder::Build("<Html/SimBlockSnipFragment.html",
127 :     { positionRow => $positionRow, set0Row => $set0Row,
128 :     set1Row => $set1Row }, "Html");
129 : parrello 1.4 $webData .= $snipData;
130 :     # Put the web page data into the variable hash.
131 :     $varHash->{Data} = $webData;
132 : parrello 1.1 };
133 :     # Trace any error that occurred.
134 :     if ($@) {
135 :     Trace($@) if T(0);
136 :     }
137 : parrello 1.4 # Write out the web page.
138 :     ScriptFinish("Html/SimBlockPattern.html", $varHash);
139 : parrello 1.1
140 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3