[Bio] / SubsystemEditor / WebPage / ShowVariants.pm Repository:
ViewVC logotype

Diff of /SubsystemEditor/WebPage/ShowVariants.pm

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

revision 1.2, Fri Aug 31 20:43:46 2007 UTC revision 1.12, Mon May 11 14:12:46 2009 UTC
# Line 21  Line 21 
21    
22    $self->application->register_component(  'Table', 'ShowVariantsTable'  );    $self->application->register_component(  'Table', 'ShowVariantsTable'  );
23    $self->application->register_component(  'Table', 'FRTable'  );    $self->application->register_component(  'Table', 'FRTable'  );
24      $self->application->register_component( 'Table', 'VarDescTable'  );
25      $self->application->register_component( 'Info', 'CommentInfo');
26  }  }
27    
28  sub require_javascript {  sub require_javascript {
# Line 35  Line 37 
37  sub output {  sub output {
38    my ( $self ) = @_;    my ( $self ) = @_;
39    
40    my $can_alter = 1;    my $can_alter = 0;
41      my $user = $self->application->session->user;
42    
43    my $fig = new FIG;    $self->{ 'fig' } = $self->application->data_handle( 'FIG' );
44    my $cgi = $self->application->cgi;    $self->{ 'cgi' } = $self->application->cgi;
45    
46    my $name = $cgi->param( 'subsystem' );    my $name = $self->{ 'cgi' }->param( 'subsystem' );
47    my $ssname = $name;    my $ssname = $name;
48      $name = uri_unescape( $name );
49    $ssname =~ s/\_/ /g;    $ssname =~ s/\_/ /g;
50    
51      my $esc_name = uri_escape($name);
52    
53      my $dbmaster = $self->application->dbmaster;
54      my $ppoapplication = $self->application->backend;
55    
56      # get a seeduser #
57      my $seeduser = '';
58      if ( defined( $user ) && ref( $user ) ) {
59        my $preferences = $dbmaster->Preferences->get_objects( { user => $user,
60                                                                 name => 'SeedUser',
61                                                                 application => $ppoapplication } );
62        if ( defined( $preferences->[0] ) ) {
63          $seeduser = $preferences->[0]->value();
64        }
65      }
66    
67      if ( $user && $user->has_right( $self->application, 'edit', 'subsystem', $name ) ) {
68        $can_alter = 1;
69        $self->{ 'fig' }->set_user( $seeduser );
70      }
71    
72    ######################    ######################
73    # Construct the menu #    # Construct the menu #
74    ######################    ######################
# Line 51  Line 76 
76    my $menu = $self->application->menu();    my $menu = $self->application->menu();
77    
78    # Build nice tab menu here    # Build nice tab menu here
79    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$name" );    $menu->add_category( 'Subsystem Info', "SubsysEditor.cgi?page=ShowSubsystem&subsystem=$esc_name" );
80    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$name" );    $menu->add_category( 'Functional Roles', "SubsysEditor.cgi?page=ShowFunctionalRoles&subsystem=$esc_name" );
81    $menu->add_category( 'Subsystem Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$name" );    $menu->add_category( 'Diagram', "SubsysEditor.cgi?page=ShowDiagram&subsystem=$esc_name" );
82    $menu->add_category( 'Subsystem Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$name" );    $menu->add_category( 'Illustrations', "SubsysEditor.cgi?page=ShowIllustrations&subsystem=$esc_name" );
83    $menu->add_category( 'Subsystem Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$name" );    $menu->add_category( 'Spreadsheet', "SubsysEditor.cgi?page=ShowSpreadsheet&subsystem=$esc_name" );
84    $menu->add_category( 'Subsystem Tree', "SubsysEditor.cgi?page=ShowTree&subsystem=$name" );    $menu->add_category( 'Show Check', "SubsysEditor.cgi?page=ShowCheck&subsystem=$esc_name" );
85      $menu->add_category( 'Show Connections', "SubsysEditor.cgi?page=ShowTree&subsystem=$esc_name" );
86    
87    
88    ##############################    ##############################
# Line 72  Line 98 
98      return $content;      return $content;
99    }    }
100    
101    my ( $datahash, $subsystem ) = get_data( $fig, $name );    $content .= $self->start_form();
102    
103      #### 100x100 ####
104      if ( defined( $self->{ 'cgi' }->param( 'on100x100' ) ) ) {
105        $self->{ 'cgi' }->param( 'hundred_hundred', 1 );
106      }
107      if ( defined( $self->{ 'cgi' }->param( 'off100x100' ) ) ) {
108        $self->{ 'cgi' }->param( 'hundred_hundred', 0 );
109      }
110    
111    
112      if ( !defined( $self->{ 'cgi' }->param( 'hundred_hundred' ) ) || $self->{ 'cgi' }->param( 'hundred_hundred' ) != 1 ) {
113        $content .= $self->{ 'cgi' }->submit( -name => "on100x100", -value => "Show only 100x100" );
114      }
115      else {
116        $content .= $self->{ 'cgi' }->submit( -name => "off100x100", -value => "Show all genomes" );
117      }
118    
119      my $subsystem = $self->{ 'fig' }->get_subsystem( $name );
120    
121      my $datahash = $self->get_data( $subsystem );
122    
123    my $application = $self->application;    my $application = $self->application;
124    
125    if ( $cgi->param( 'set_variants' ) ) {    if ( $self->{ 'cgi' }->param( 'set_variants' ) ) {
126      $comment .= '<BR>';      $comment .= '<BR>';
127      $comment .= set_variants( $cgi, $fig, $name, $subsystem, $application, $datahash );      $comment .= set_variants( $self, $name, $subsystem, $application, $datahash );
128      ( $datahash, $subsystem ) = get_data( $fig, $name );      $datahash = $self->get_data( $subsystem );
129      }
130      elsif ( $self->{ 'cgi' }->param( 'addsave_variants' ) ) {
131        my @varcodes = $self->{ 'cgi' }->param( 'VARIANT' );
132        my @vardescs = $self->{ 'cgi' }->param( 'VARIANTDESC' );
133        my %varhash;
134    
135        for ( my $i = 0; $i < scalar( @varcodes ); $i++ ) {
136    
137          if ( $varcodes[$i] eq '' ) {
138            if ( $vardescs[$i] ne '' ) {
139              $comment .= "No Variant Code given for description ".uri_unescape( $vardescs[$i] ).", so this variant could not be saved.<BR>\n";
140            }
141            next;
142          }
143          if ( defined( $varhash{ $varcodes[$i] } ) ) {
144            $comment .= "Variant ".$varcodes[$i]." already has the description ".$varhash{ $varcodes[$i] }.", so description ".uri_unescape( $vardescs[$i] )." was ignored.<BR>\n";
145            next;
146          }
147    
148          $varhash{ $varcodes[$i] } = uri_unescape( $vardescs[$i] );
149    }    }
150        my $newvarcode = $self->{ 'cgi' }->param( 'NEWVARIANT' );
151        my $newvardesc = $self->{ 'cgi' }->param( 'NEWVARIANTDESC' );
152        if ( defined( $newvarcode ) && $newvarcode ne '' && defined( $newvardesc ) && $newvardesc ne '' ) {
153          if ( $newvarcode eq '' ) {
154            if ( $newvarcode ne '' ) {
155              $comment .= "No Variant Code given for description ".uri_unescape( $newvardesc ).", so this variant could not be saved.<BR>\n";
156            }
157          }
158          elsif ( defined( $varhash{ $newvarcode } ) ) {
159            $comment .= "Variant $newvarcode already has the description ".uri_unescape( $newvardesc ).", so description ".uri_unescape( $newvardesc )." was ignored.<BR>\n";
160          }
161          else {
162            $varhash{ $newvarcode } = uri_unescape( $newvardesc );
163          }
164        }
165    
166        $subsystem->set_variants( \%varhash );
167        $subsystem->incr_version();
168        $subsystem->db_sync();
169        $subsystem->write_subsystem();
170      }
171    
172      if ( defined( $comment ) && $comment ne '' ) {
173        my $info_component = $application->component( 'CommentInfo' );
174    
175        $info_component->content( $comment );
176        $info_component->default( 0 );
177        $content .= $info_component->output();
178      }
179    
180    
181    $content .= show_variants( $self, $cgi, $fig, $name, $subsystem, $datahash );    $content .= show_variants( $self, $name, $subsystem, $can_alter, $datahash );
182    
183    ###############################    ###############################
184    # Display errors and comments #    # Display errors and comments #
# Line 91  Line 187 
187    if ( defined( $error ) && $error ne '' ) {    if ( defined( $error ) && $error ne '' ) {
188      $self->application->add_message( 'warning', $error );      $self->application->add_message( 'warning', $error );
189    }    }
   if ( defined( $comment ) && $comment ne '' ) {  
     $self->application->add_message( 'info', $comment );  
   }  
   
190    return $content;    return $content;
191  }  }
192    
# Line 102  Line 194 
194  # data method #  # data method #
195  ###############  ###############
196  sub get_data {  sub get_data {
197    my ( $fig, $name ) = @_;    my ( $self, $subsystem ) = @_;
198    
199    my $datahash = {};    my $datahash = {};
200    
   my $subsystem = $fig->get_subsystem( $name );  
201    my @genomes        = $subsystem->get_genomes;    my @genomes        = $subsystem->get_genomes;
202    
203      my %thesegenomes;
204    
205      if ( defined( $self->{ 'cgi' }->param( 'hundred_hundred' ) ) && $self->{ 'cgi' }->param( 'hundred_hundred' ) == 1 ) {
206        my %orgs = map { $_->[0] => 1 } grep { $_->[0] =~ /^\d+\.\d+$/ } $self->{ 'fig' }->get_attributes( undef, 'collection', 'hundred_hundred' );
207    
208        foreach my $g ( @genomes ) {
209          if ( defined( $orgs{ $g } ) ) {
210            $thesegenomes{ $g } = 1;
211          }
212        }
213        @genomes = keys %thesegenomes;
214      }
215    
216    my %variant_codes = map { $_ => $subsystem->get_variant_code( $subsystem->get_genome_index( $_ ) ) } @genomes;    my %variant_codes = map { $_ => $subsystem->get_variant_code( $subsystem->get_genome_index( $_ ) ) } @genomes;
217    my @roles          = $subsystem->get_roles;    my @roles          = $subsystem->get_roles;
218    
# Line 115  Line 220 
220    $datahash->{ 'varcodes' } = \%variant_codes;    $datahash->{ 'varcodes' } = \%variant_codes;
221    $datahash->{ 'roles' } = \@roles;    $datahash->{ 'roles' } = \@roles;
222    
223    return ( $datahash, $subsystem );    return $datahash;
224  }  }
225    
226  #########################################################  #########################################################
227  # show table with variants and button for changing them #  # show table with variants and button for changing them #
228  #########################################################  #########################################################
229  sub show_variants {  sub show_variants {
230    my ( $self, $cgi, $fig, $name, $sub, $datahash ) = @_;    my ( $self, $name, $sub, $can_alter, $datahash ) = @_;
231    
232    my $application = $self->application();    my $application = $self->application();
233    
# Line 133  Line 238 
238    my %variant_codes = %{ $datahash->{ 'varcodes' } };    my %variant_codes = %{ $datahash->{ 'varcodes' } };
239    my @roles          = @{ $datahash->{ 'roles' } };    my @roles          = @{ $datahash->{ 'roles' } };
240    
241    my ( $abbrev, $frtable ) = format_roles( $application, $fig, $cgi, $sub );    my ( $abbrev, $frtable ) = $self->format_roles( $sub );
242    
243    my( @has, $role, %has_filled );    my( @has, $role, %has_filled );
244    foreach my $genome ( @genomes ) {    foreach my $genome ( @genomes ) {
# Line 145  Line 250 
250      $has_filled{join(",",@has)}->{$variant_codes{$genome}}++;      $has_filled{join(",",@has)}->{$variant_codes{$genome}}++;
251    }    }
252    
253    my ( $col_hdrs, $tab, $pattern );    my ( $col_hdrs, $pattern_uq );
254      if ( $can_alter ) {
255    $col_hdrs = [ { name => "Pattern" }, { name => "# Genomes with Pattern" },    $col_hdrs = [ { name => "Pattern" }, { name => "# Genomes with Pattern" },
256                  { name => "Existing Variant Code" }, { name => "Set To" } ];                  { name => "Existing Variant Code" }, { name => "Set To" } ];
257    $tab = [];    }
258    foreach $pattern ( sort keys( %has_filled ) ) {    else {
259        $col_hdrs = [ { name => "Pattern" }, { name => "# Genomes with Pattern" },
260                      { name => "Existing Variant Code" } ];
261      }
262    
263      my $tab = [];
264      foreach $pattern_uq ( sort keys( %has_filled ) ) {
265    
266        my $pattern = quotemeta( $pattern_uq );
267    
268      my @codes = keys( %{ $has_filled{ $pattern } } );      my @codes = keys( %{ $has_filled{ $pattern_uq } } );
269      my $code;      my $code;
270      my $nrow = @codes;      my $nrow = @codes;
271      if ( @codes > 0 ) {      if ( @codes > 0 ) {
272        $code = shift @codes;        $code = shift @codes;
273        push( @$tab, [ $pattern,        if ( $can_alter ) {
274                       $has_filled{$pattern}->{$code},          push( @$tab, [ $pattern_uq,
275                           $has_filled{ $pattern_uq }->{ $code },
276                       $code,                       $code,
277                       $cgi->textfield(-name => "p:$pattern:$code", -size => 5, -value => $code, -override => 1)                         $self->{ 'cgi' }->textfield(-name => "p##:##$pattern##:##$code", -size => 5, -value => $code, -override => 1)
278                         ]);
279          }
280          else {
281            push( @$tab, [ $pattern_uq,
282                           $has_filled{ $pattern_uq }->{ $code },
283                           $code
284                     ]);                     ]);
285      }      }
286        }
287    
288      foreach $code ( @codes ) {      foreach $code ( @codes ) {
289          if ( $can_alter ) {
290        push( @$tab,[ $has_filled{ $pattern }->{ $code },          push( @$tab, [ $pattern_uq,
291                           $has_filled{ $pattern_uq }->{ $code },
292                      $code,                      $code,
293                      $cgi->textfield(-name => "p:$pattern:$code", -size => 5, -value => $code, -override => 1)                         $self->{ 'cgi' }->textfield( -name => "p##:##$pattern##:##$code", -size => 5, -value => $code, -override => 1)
294                    ]);                    ]);
295      }      }
296          else {
297            push( @$tab, [ $pattern_uq,
298                           $has_filled{ $pattern_uq }->{ $code },
299                           $code
300                         ]);
301          }
302        }
303    }    }
304    
305    $cont .= $frtable;    $cont .= $frtable;
   $cont .= $self->start_form();  
306    
307    # create table from parsed data    my $thistable = create_table( $self, \%has_filled, $col_hdrs, $tab );
308    my $table = $application->component( 'ShowVariantsTable' );  
309    $table->columns( $col_hdrs );    ############################################
310    $table->data( $tab );    # Variant Descriptions from the Notes file #
311      ############################################
312      $cont .= "<H2>Variant descriptions</H2>\n";
313      my $variants = $sub->get_variants();
314    
315      my $infotable = '';
316      if ( $can_alter ) {
317        $infotable .= "<TABLE class='table_table'><TR><TD class='table_first_row'>Variant</TD><TD class='table_first_row'>Description</TD></TR>";
318        foreach my $kv ( sort keys %$variants ) {
319          my $esc_kvd = $variants->{ $kv };
320          $esc_kvd =~ s/'/&#39;/g;
321          $infotable .= "<TR><TD class='table_odd_row'>";
322          $infotable .= $self->{ 'cgi' }->textfield( -name => "VARIANT", -id => "VARIANT", -size => 20, -value => $kv, -override => 1 );
323          $infotable .= "</TD><TD class='table_odd_row'>";
324          $infotable .= $self->{ 'cgi' }->textfield( -name => "VARIANTDESC", -id => "VARIANTDESC", -size => 70, -value => $variants->{ $kv }, -override => 1 );
325          $infotable .= "</TD></TR>";
326        }
327        $infotable .= "<TR><TD class='table_odd_row'>";
328        $infotable .= $self->{ 'cgi' }->textfield( -name => "NEWVARIANT", -id => "NEWVARIANT", -size => 20, -override => 1 );
329        $infotable .= "</TD><TD class='table_odd_row'>";
330        $infotable .= $self->{ 'cgi' }->textfield( -name => "NEWVARIANTDESC", -id => "NEWVARIANTDESC", -size => 70, -override => 1 );
331        $infotable .= "</TD></TR>";
332        $infotable .= "<TR><TD>";
333        $infotable .= $self->{ 'cgi' }->submit( -name => "addsave_variants", -value => "Add/Save Variants" );
334        $infotable .= "</TD></TR></TABLE>";
335    
336        $cont .= $infotable;
337      }
338      else {
339        my $infotable = $application->component( 'VarDescTable' );
340        $infotable->columns( [ { name => "Variant" }, { name => "Description" } ] );
341    
342        my $vardata;
343        foreach my $kv ( sort keys %$variants ) {
344          push @$vardata, [ $kv, $variants->{ $kv } ];
345        }
346        $infotable->data( $vardata );
347        $cont .= $infotable->output();
348      }
349    
350      my $esc_name = uri_escape($name);
351    
352    $cont .= "<H2>Variant groups</H2>\n";    $cont .= "<H2>Variant groups</H2>\n";
353    $cont .= $application->component( 'ShowVariantsTable' )->output();    $cont .= $thistable;
354    
355      $cont .= $self->{ 'cgi' }->hidden(-name => 'request', -value => 'set_variants', -override => 1);
356      $cont .= $self->{ 'cgi' }->hidden(-name => 'subsystem', -value => $name, -override => 1 );
357    
358      if ( defined( $self->{ 'cgi' }->param( 'hundred_hundred' ) ) ) {
359        $cont .= $self->{ 'cgi' }->hidden(-name => 'hundred_hundred', -value => $self->{ 'cgi' }->param( 'hundred_hundred' ), -override => 1 );
360      }
361    
362    $cont .= $cgi->hidden(-name => 'request', -value => 'set_variants', -override => 1);    if ( $can_alter ) {
363    $cont .= $cgi->hidden(-name => 'subsystem', -value => $name, -override => 1);      $cont .= $self->{ 'cgi' }->br;
364    $cont .= $cgi->br;    }
365    $cont .= $cgi->submit( -name => "set_variants", -value => "Set Variants" );    $cont .= $self->{ 'cgi' }->submit( -name => "set_variants", -value => "Set Variants" );
366    $cont .= $self->end_form();    $cont .= $self->end_form();
367    
368    return $cont;    return $cont;
# Line 196  Line 373 
373  # get a functional role table #  # get a functional role table #
374  ###############################  ###############################
375  sub format_roles {  sub format_roles {
376      my( $application, $fig, $cgi, $subsystem ) = @_;      my( $self, $subsystem ) = @_;
377      my( $i );      my( $i );
378    
379      my $col_hdrs = [ "Column", "Abbrev", "Functional Role" ];      my $col_hdrs = [ "Column", "Abbrev", "Functional Role" ];
380    
381      my $n = 1;      my ( $tab, $abbrevP ) = $self->format_existing_roles( $subsystem );
     my ( $tab, $abbrevP ) = format_existing_roles( $fig, $subsystem, \$n );  
382    
383      # create table from parsed data      # create table from parsed data
384      my $table = $application->component( 'FRTable' );      my $table = $self->application->component( 'FRTable' );
385      $table->columns( $col_hdrs );      $table->columns( $col_hdrs );
386      $table->data( $tab );      $table->data( $tab );
387    
388      my $formatted = '<H2>Functional Roles</H2>';      my $formatted = '<H2>Functional Roles</H2>';
389      $formatted .= $application->component( 'FRTable' )->output();      $formatted .= $self->application->component( 'FRTable' )->output();
390    
391      $formatted .= "<BR><BR>";      $formatted .= "<BR><BR>";
392      return ( $abbrevP, $formatted );      return ( $abbrevP, $formatted );
# Line 220  Line 396 
396  # get rows of the functional role table #  # get rows of the functional role table #
397  #########################################  #########################################
398  sub format_existing_roles {  sub format_existing_roles {
399      my ( $fig, $subsystem, $nP ) = @_;      my ( $self, $subsystem ) = @_;
400      my $tab = [];      my $tab = [];
401      my $abbrevP = {};      my $abbrevP = {};
402    
# Line 228  Line 404 
404        my $i = $subsystem->get_role_index( $role );        my $i = $subsystem->get_role_index( $role );
405        my $abbrev = $role ? $subsystem->get_role_abbr( $i ) : "";        my $abbrev = $role ? $subsystem->get_role_abbr( $i ) : "";
406        $abbrevP->{ $role } = $abbrev;        $abbrevP->{ $role } = $abbrev;
407        push( @$tab, [ $$nP, $abbrev, $role ] );        push( @$tab, [ $i + 1, $abbrev, $role ] );
408      }      }
409    
410      return ( $tab, $abbrevP );      return ( $tab, $abbrevP );
# Line 239  Line 415 
415  # change the variants in the subsystems file #  # change the variants in the subsystems file #
416  ##############################################  ##############################################
417  sub set_variants {  sub set_variants {
418      my ( $cgi, $fig, $subsys, $sub, $application, $datahash ) = @_;      my ( $self, $subsys, $sub, $application, $datahash ) = @_;
419    
420      my @genomes        = @{ $datahash->{ 'genomes' } };      my @genomes        = @{ $datahash->{ 'genomes' } };
421      my %variant_codes = %{ $datahash->{ 'varcodes' } };      my %variant_codes = %{ $datahash->{ 'varcodes' } };
422      my @roles          = @{ $datahash->{ 'roles' } };      my @roles          = @{ $datahash->{ 'roles' } };
423    
424      my ( $abbrev, $frtable ) = format_roles( $application, $fig, $cgi, $sub );      my ( $abbrev, $frtable ) = $self->format_roles( $sub );
425    
426      my ( %genomes_with );      my ( %genomes_with );
427      foreach my $genome ( @genomes ) {      foreach my $genome ( @genomes ) {
# Line 255  Line 431 
431        foreach my $role ( @roles ) {        foreach my $role ( @roles ) {
432          push( @has, ( $sub->get_pegs_from_cell( $genome, $role ) > 0 ) ? $abbrev->{ $role } : () );          push( @has, ( $sub->get_pegs_from_cell( $genome, $role ) > 0 ) ? $abbrev->{ $role } : () );
433        }        }
434        my $pattern = join( ",", @has );        my $pattern = quotemeta( join( ",", @has ) );
435        push( @{ $genomes_with{ "$pattern, $vc" } }, $genome );        push( @{ $genomes_with{ "$pattern, $vc" } }, $genome );
436      }      }
437    
438      my $comment = '';      my $comment = '';
439        my @params = grep { $_ =~ /^p##:##/ } $self->{ 'cgi' }->param;
440    
     my @params = grep { $_ =~ /^p:/ } $cgi->param;  
441      foreach my $param (@params) {      foreach my $param (@params) {
442        if ( $param =~ /^p:(.*):(.*)$/ ) {  
443          if ( $param =~ /^p##:##(.*)##:##(.*)$/ ) {
444          my ( $pattern, $vc ) = ( $1, $2 );          my ( $pattern, $vc ) = ( $1, $2 );
445    
446          $pattern =~ s/ //g;          $pattern =~ s/ //g;
447          $vc      =~ s/ //g;          $vc      =~ s/ //g;
448          my $to = $cgi->param( $param );          my $to = $self->{ 'cgi' }->param( $param );
449    
450          if ( my $x = $genomes_with{ "$pattern, $vc" } ) {          if ( my $x = $genomes_with{ "$pattern, $vc" } ) {
   
451            foreach my $genome ( @$x ) {            foreach my $genome ( @$x ) {
452    
453              if ( $to ne $variant_codes{ $genome } ) {              if ( $to ne $variant_codes{ $genome } ) {
454    
455                my $old = $variant_codes{$genome};                my $old = $variant_codes{$genome};
456                my $gs = $fig->genus_species($genome);                my $gs = $self->{ 'fig' }->genus_species( $genome );
457                $comment .= "resetting $genome $gs from $old to $to<BR>\n";                $comment .= "resetting $genome $gs from $old to $to<BR>\n";
458                $sub->set_variant_code( $sub->get_genome_index( $genome ), $to );                $sub->set_variant_code( $sub->get_genome_index( $genome ), $to );
459              }              }
460            }            }
   
461          }          }
462        }        }
463      }      }
464    
465        $sub->incr_version();
466        $sub->db_sync();
467      $sub->write_subsystem();      $sub->write_subsystem();
468    
469      return $comment;      return $comment;
470  }  }
471    
472    sub create_table {
473      my ( $self, $has_filled, $col_hdrs, $tab ) = @_;
474    
475      my $in;
476      my $tabl = "<TABLE class='table_table'><TR>";
477    
478      foreach my $ch ( @$col_hdrs ) {
479        $tabl .= "<TD class='table_first_row'>";
480        $tabl .= $ch->{ name };
481        $tabl .= "</TD>";
482      }
483    
484      foreach my $r ( @$tab ) {
485        $tabl .= "<TR>";
486    
487        my $num = scalar( keys %{ $has_filled->{ $r->[0] } } );
488        my $pat = $r->[0];
489        if ( $num > 1 ) {
490          if ( !$in->{ $pat } ) {
491            $tabl .= "<TD rowspan=$num class='table_odd_row' STYLE='vertical-align: middle;'>".$r->[0]."</TD>";
492            $in->{ $pat } = 1;
493          }
494        }
495        else {
496          $tabl .= "<TD class='table_odd_row'>".$r->[0]."</TD>";
497        }
498        my $next = 0;
499        foreach my $cell ( @$r ) {
500          if ( $next == 0 ) {
501            $next = 1;
502            next;
503          }
504          else {
505            $tabl .= "<TD class='table_odd_row'>".$cell."</TD>";
506          }
507        }
508        $tabl .= "</TR>";
509      }
510    
511      $tabl .= "</TABLE>";
512    
513      return $tabl;
514    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.12

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3