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

Diff of /FigWebServices/SimBlockPattern.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed May 4 03:17:43 2005 UTC revision 1.5, Fri Jul 28 02:07:28 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    #
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    
20  BEGIN {  BEGIN {
21      # Print the HTML header.      # Print the HTML header.
# Line 19  Line 36 
36  record.  record.
37    
38  For debugging purposes, you can specify the B<Trace> parameter to  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  set the tracing level. So, for example,
 C<1> to display a table of the parameters passed by the form. So,  
 for example,  
40    
41  C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3 >>  C<< http://myseedurl/CGI/SimBlockPattern.cgi?Trace=3 >>
42    
# Line 42  Line 57 
57  use PageBuilder;  use PageBuilder;
58  use SimBlocks;  use SimBlocks;
59    
60  # Get the CGI parameters.  # Get the CGI parameters and set up the variable hash.
61  my $query = new CGI;  my ($query, $varHash) = ScriptSetup();
62  my $traceLevel = $query->param("Trace");  # Do this next part safely.
63  if (!defined $traceLevel || length $traceLevel == 0) {  eval {
     $traceLevel = "0";  
 }  
 TSetup("$traceLevel Tracer", "QUEUE");  
   
64  # Our first task is to get the parameters. We need a list of the IDs of the selected  # 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 "set1Genomes" and "set2Genomes" parameters.      # genomes. These lists will be found in the "set0Genomes" and "set1Genomes" parameters.
66    
67  my @genomes = ();      my @set0 = $query->param("set0Genomes");
68  push @genomes, $query->param("set1Genomes"), $query->param("set2Genomes");      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  # Next, we need to get the block ID. The block ID is going to be the value of the
72  # "set1Blocks", "set2Blocks", or "bothBlocks" parameter, depending on whether the      # "set0Blocks", "set1Blocks", or "bothBlocks" parameter, depending on whether the
73  # "set1Button", "set2Button", or "bothButton" parameter is present.      # "set0Button", "set1Button", or "bothButton" parameter is present.
74  my $blockID;  my $blockID;
75  for my $setID ('set1', 'both', 'set2') {      for my $setID ('set0', 'both', 'set1') {
76      my $thisBlockID = $query->param("${setID}Blocks");      my $thisBlockID = $query->param("${setID}Blocks");
77      if ($thisBlockID && $query->param("${setID}Button")) {      if ($thisBlockID && $query->param("${setID}Button")) {
78          $blockID = $thisBlockID;          $blockID = $thisBlockID;
# Line 68  Line 80 
80  }  }
81  Trace("Block $blockID selected for genomes " . join ", ", @genomes) if T(2);  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  # Now we have all the information we need to produce the alignment. We need to
83  # create the similarity block object and start the web page.      # create the similarity block object and start the big block in the middle of
84        # the web page.
85  my $simBlock = SimBlocks->new();  my $simBlock = SimBlocks->new();
86  my $builder = PageBuilder::new("Html/SimBlockPattern.html", {}, "Html");      my $webData = "";
 # Protect against errors.  
 eval {  
87      # Next we need the template fragment for the rows.      # Next we need the template fragment for the rows.
88      my $rowFragment = Tracer::GetFile("Html/SimBlockPatternRow.html");      my $rowFragment = Tracer::GetFile("Html/SimBlockPatternRow.html");
89      # Get the block from the similarity block database and extract its pattern.      # Get the block from the similarity block database and extract its pattern.
90      my $blockData = $simBlock->GetEntity('GroupBlock', $blockID);      my $blockData = $simBlock->GetBlock($blockID);
91      my ($pattern) = $blockData->Value('GroupBlock(pattern)');      my ($pattern) = $blockData->Value('GroupBlock(pattern)');
92      # Get the regions for the block.      # Get the regions for the block.
93      my %regions = $simBlock->GetRegions($blockID, \@genomes);      my %regions = $simBlock->GetRegions($blockID, \@genomes);
94      for my $region (sort keys %regions) {      for my $region (sort keys %regions) {
95          my $dna = $regions{$region};          my $dna = $regions{$region};
96            # Get this region's set number.
97            my $setNumber = SimBlocks::SetNumber($region, \@set0, \@set1);
98          # Mark the variant columns with EM tags.          # Mark the variant columns with EM tags.
99          $dna = SimBlocks::TagDNA($pattern, $dna, "<em>", "</em>");          $dna = SimBlocks::TagDNA($pattern, $dna, "<em>", "</em>");
100          # Create a table row for this region.          # Create a table row for this region.
101          my $row = PageBuilder::Build($rowFragment, { region => $region,          my $row = PageBuilder::Build($rowFragment, { region => $region, dna => $dna,
102                                                       dna => $dna }, "Html");                                                       setNumber => $setNumber }, "Html");
103          print $row;          $webData .= $row;
104      }      }
105        # 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        $webData .= $snipData;
130        # Put the web page data into the variable hash.
131        $varHash->{Data} = $webData;
132  };  };
133  # Trace any error that occurred.  # Trace any error that occurred.
134  if ($@) {  if ($@) {
135      Trace($@) if T(0);      Trace($@) if T(0);
136  }  }
137  # Write out any trace messages.  # Write out the web page.
138  my $qtrace = QTrace("html");  ScriptFinish("Html/SimBlockPattern.html", $varHash);
 print $qtrace;  
 # Finish the web page.  
 $builder->Finish();  
139    
140  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3