[Bio] / FigKernelPackages / Subsystem.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Subsystem.pm

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

revision 1.1, Mon May 24 21:55:18 2004 UTC revision 1.2, Tue May 25 16:19:23 2004 UTC
# Line 8  Line 8 
8    
9  use strict;  use strict;
10    
11  #  =pod
12  # Subsystem manipulation.  
13  #  =head1 Subsystem manipulation.
14  # Any manipulation of subsystem data should happen through this interface.  
15  # This allows us to assure ourselves that the relational tables that  Any manipulation of subsystem data should happen through this interface.
16  # mirror and index the subsystem data are kept up to date with the  This allows us to assure ourselves that the relational tables that
17  # canonical version of the subsystem information in the flat-files  mirror and index the subsystem data are kept up to date with the
18  # kept in $FIG_Config::data/Subsystems.  canonical version of the subsystem information in the flat-files
19  #  kept in $FIG_Config::data/Subsystems.
20  # Thoughts on locking  
21  #  =head2 Thoughts on locking
22  # It is currently dangerous for multiple users to modify spreadsheets at once.  
23  # It will likely remain dangerous while the subsystem backend is fairly  It is currently dangerous for multiple users to modify spreadsheets at once.
24  # stateless, as it is with the CGI mechanism.  It will likely remain dangerous while the subsystem backend is fairly
25  #  stateless, as it is with the CGI mechanism.
26  # We'd like to make this a little safer. One mechanism might be to allow  
27  # a user to open a subsystem for modification, and others for readonly access.  We'd like to make this a little safer. One mechanism might be to allow
28  # For this to work we have to be able to tell which users is allowed; current  a user to open a subsystem for modification, and others for readonly access.
29  # implementation uses the curator of the subsystem for this purpose.  For this to work we have to be able to tell which users is allowed; current
30  #  implementation uses the curator of the subsystem for this purpose.
31  # NB: This module does not currently attempt to handle locking or exclusion.  
32  # It is up to the caller (user application, CGI script, etc) to do so.  NB: This module does not currently attempt to handle locking or exclusion.
33  # It does attempt to use locking internally where appropriate.  It is up to the caller (user application, CGI script, etc) to do so.
34  #  It does attempt to use locking internally where appropriate.
35  # Data structures  
36  #  =head2 Data structures
37  # We maintain the following data structures (all members of %$self).  
38  #  We maintain the following data structures (all members of %$self).
39  # roles: list of role names  
40  # role_index: hash that maps from role name to index  =over 4
41  # role_abbrs: list of role abbreviations  
42  # col_subsets: list of column subset names  =item dir
43  # col_subset_members: hash that maps from column subset name to subset members  
44  # col_subset_active: currently-active column subset  Directory in which the subsystem is stored.
45  # row_subset_active: currently-active row subset  
46  #  =item notes
47    
48    The current notes contents for the subsystem
49    
50    =item version
51    
52    Current subsystem version.
53    
54    =item exchangable
55    
56    1 if subsystem is exchangable, 0 otherwise.
57    
58    
59    =item roles
60    
61    list of role names
62    
63    =item role_index
64    
65    hash that maps from role name to index
66    
67    =item role_abbrs
68    
69    list of role abbreviations
70    
71    =item abbr
72    
73    hash mapping from role abbreviation to role name
74    
75    =item col_subsets
76    
77    list of column subset names
78    
79    =item col_subset_members
80    
81    hash that maps from column subset name to subset members
82    
83    =item col_active_subset
84    
85    currently-active column subset
86    
87    =item row_active_subset
88    
89    currently-active row subset
90    
91    =item genome
92    
93    List (1-indexed, so element 0 is undef) of genome IDs.
94    
95    =item variant_code
96    
97    List (1-indexed, so element 0 is undef) of variant codes.
98    
99    =item genome_index
100    
101    Hash mapping from genome ID to genome index.
102    
103    =item variant_code
104    
105    List (1-indexed, so element 0 is undef) of variant codes.
106    
107    =item spreadsheet
108    
109    Spreadsheet data. Structured as a list of rows, each of  which
110    is a list of entries. An entry is a list of PEG numbers.
111    
112    =item spreadsheet_inv
113    
114    Inverted structure of spreadsheet - list of columns, each of which is a list
115    of rows.
116    
117    =back
118    
119    =cut
120    
121  use FIG;  use FIG;
122    
# Line 199  Line 272 
272      for my $role (@roles)      for my $role (@roles)
273      {      {
274          my($abbr, $name) = split(/\t/, $role);          my($abbr, $name) = split(/\t/, $role);
275          print "Role $i: abbr=$abbr name=$name\n";          # print "Role $i: abbr=$abbr name=$name\n";
276    
277          $self->{abbr}->{$abbr} = $name;          $self->{abbr}->{$abbr} = $name;
278          $self->{role_index}->{$name} = $i;          $self->{role_index}->{$name} = $i;
279          $self->{roles}->[$i] = $name;          $self->{roles}->[$i] = $name;
280            $self->{role_abbrs}->[$i] = $name;
281          $i++;          $i++;
282      }      }
283  }  }
# Line 212  Line 286 
286  {  {
287      my($self, $subsets) = @_;      my($self, $subsets) = @_;
288    
     print "Load subsets: '$subsets'\n";  
   
289      #      #
290      # Column and row subsets.      # Column and row subsets.
291      #      #
# Line 225  Line 297 
297      #      #
298    
299      my @subsetsC = split(/\n/, $subsetsC);      my @subsetsC = split(/\n/, $subsetsC);
     print "subsetsC: ", join(":", @subsetsC), "\n";  
300    
301      #      #
302      # Determine active subset.      # Determine active subset.
# Line 247  Line 318 
318      for my $subset (@subsetsC)      for my $subset (@subsetsC)
319      {      {
320          my($name, @members) = split(/\s+/, $subset);          my($name, @members) = split(/\s+/, $subset);
         print "Name:$ name members: @members\n";  
321    
322          push(@{$self->{col_subsets}}, $name);          push(@{$self->{col_subsets}}, $name);
323    
# Line 267  Line 337 
337              }              }
338          } @members;          } @members;
339    
         print "New members: @members\n";  
340          @{$self->{col_subset_members}->{$name}} = @members;          @{$self->{col_subset_members}->{$name}} = @members;
341      }      }
342    
# Line 320  Line 389 
389      }      }
390  }  }
391    
392    =pod
393    
394    =head1 get_genomes
395    
396    =cut
397    
398    sub get_genomes
399    {
400        my($self) = @_;
401    
402        my $glist = $self->{genome};
403    
404        return @$glist[1..$#$glist];
405    }
406    
407    =pod
408    
409    =head1 get_variant_codes
410    
411    =cut
412    
413    sub get_variant_codes
414    {
415        my($self) = @_;
416    
417        my $glist = $self->{variant_code};
418    
419        return @$glist[1..$#$glist];
420    }
421    
422    sub get_variant_code_for_genome
423    {
424        my($self, $genome) = @_;
425    
426        my $index = $self->{genome_index}->{$genome};
427        return $self->{variant_code}->[$index];
428    }
429    
430    sub get_roles
431    {
432        my($self) = @_;
433    
434        my $rlist = $self->{roles};
435    
436        return @$rlist[1..$#$rlist];
437    }
438    
439  sub get_row  sub get_row
440  {  {
441      my($self, $row) = @_;      my($self, $row) = @_;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3