[Bio] / Sprout / BaseSproutLoader.pm Repository:
ViewVC logotype

Diff of /Sprout/BaseSproutLoader.pm

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

revision 1.2, Wed Oct 1 03:07:08 2008 UTC revision 1.6, Thu Apr 2 01:32:06 2009 UTC
# Line 22  Line 22 
22      use strict;      use strict;
23      use Tracer;      use Tracer;
24      use ERDB;      use ERDB;
25        use FIG;
26      use Time::HiRes;      use Time::HiRes;
27      use base 'ERDBLoadGroup';      use base 'ERDBLoadGroup';
28    
# Line 37  Line 38 
38    
39  =head3 new  =head3 new
40    
41      my $sl = BaseSproutLoader->new($erdb, $source, $options, @tables);      my $sl = BaseSproutLoader->new($erdb, $options, @tables);
42    
43  Construct a new BaseSproutLoader object.  Construct a new BaseSproutLoader object.
44    
# Line 65  Line 66 
66    
67  sub new {  sub new {
68      # Get the parameters.      # Get the parameters.
69      my ($class, $erdb, $source, $options, @tables) = @_;      my ($class, $erdb, $options, @tables) = @_;
70      # Create the BaseSproutLoader object.      # Create the base load group object.
71      my $retVal = ERDBLoadGroup::new($class, $source, $erdb, $erdb->LoadDirectory(),      my $retVal = ERDBLoadGroup::new($class, $erdb, $options, @tables);
                                     $options, @tables);  
72      # Return it.      # Return it.
73      return $retVal;      return $retVal;
74  }  }
# Line 92  Line 92 
92    
93  =item genomeID  =item genomeID
94    
95  ID of the genome who's attributes are desired.  ID of the genome whose attributes are desired.
96    
97  =item fids  =item fids (optional)
98    
99  Reference to a list of feature IDs whose attributes are to be kept. If it is a list  Reference to a list of feature IDs whose attributes are to be kept. If it is a list
100  of lists, the feature IDs will be taken from the first element in each sub-list.  of lists, the feature IDs will be taken from the first element in each sub-list.
# Line 112  Line 112 
112  sub GetGenomeAttributes {  sub GetGenomeAttributes {
113      # Get the parameters.      # Get the parameters.
114      my ($self, $genomeID, $fids) = @_;      my ($self, $genomeID, $fids) = @_;
115        # Get the source object.
116        my $fig = $self->source();
117      # Start a timer.      # Start a timer.
118      my $start = time();      my $start = time();
119        # Initalize the FID list if we don't already have it.
120        if (! defined $fids) {
121            $fids = [ $fig->all_features($genomeID) ];
122        }
123      # Declare the return variable and initialize it with all the features.      # Declare the return variable and initialize it with all the features.
124      my %retVal = map { (ref $_ ? $_->[0] : $_) => [] } @$fids;      my %retVal = map { (ref $_ ? $_->[0] : $_) => [] } @$fids;
     # Get the source object.  
     my $fig = $self->source();  
125      # Get the attributes. If ev_code_cron is running, we may get a timeout error, so      # Get the attributes. If ev_code_cron is running, we may get a timeout error, so
126      # an eval is used.      # an eval is used.
127      my @aList = ();      my @aList = ();
# Line 187  Line 191 
191          # No, so compute the list and then create the file.          # No, so compute the list and then create the file.
192          my @subs = $fig->all_subsystems();          my @subs = $fig->all_subsystems();
193          for my $sub (@subs) {          for my $sub (@subs) {
194              if ($fig->nmpdr_subsystem($sub)) {              # Only keep NMPDR subsystems that exist on disk.
195                if ($fig->nmpdr_subsystem($sub) && ! $fig->is_experimental_subsystem($sub)) {
196                  push @retVal, $sub;                  push @retVal, $sub;
197              }              }
198          }          }
199          Tracer::PutFile($subFileName, \@retVal);          Tracer::PutFile($subFileName, \@retVal);
200      }      }
201        Trace(scalar(@retVal) . " subsystems in list.") if T(ERDBLoadGroup => 3);
202      # Return the result.      # Return the result.
203      my %retVal = map { $_ => 1 } @retVal;      my %retVal = map { $_ => 1 } @retVal;
204      return \%retVal;      return \%retVal;
# Line 201  Line 207 
207    
208  =head3 GetSectionList  =head3 GetSectionList
209    
210      my @sections = BaseSproutLoader::GetSectionList($sprout, $fig);      my @sections = BaseSproutLoader::GetSectionList($sprout, fig, $directory);
211    
212  Return a list of the sections for a Sprout load. The section list is  Return a list of the sections for a Sprout load. The section list is
213  normally determined by retrieving a list of all the complete genomes and  normally determined by retrieving a list of all the complete genomes and
# Line 220  Line 226 
226    
227  [[FigPm]] object from which the data is being retrieved.  [[FigPm]] object from which the data is being retrieved.
228    
229    =item directory (optional)
230    
231    Directory from which the Sprout tables are being loaded.
232    
233  =item RETURN  =item RETURN
234    
235  Returns a list of section names.  Returns a list of section names.
# Line 229  Line 239 
239  =cut  =cut
240    
241  sub GetSectionList {  sub GetSectionList {
242      my ($sprout, $fig) = @_;      my ($sprout, $fig, $directory) = @_;
243      # Declare the return variable.      # Declare the return variable.
244      my @retVal;      my @retVal;
245        # Insure we have a data directory.
246        $directory ||= $sprout->LoadDirectory();
247      # Look for the section list in the data directory.      # Look for the section list in the data directory.
248      my $sectionFileName = $sprout->LoadDirectory() . "/" .      my $sectionFileName = $directory . "/" .
249          ERDBGenerate::CreateFileName('section_master', undef, 'control');          ERDBGenerate::CreateFileName('section_master', undef, 'control');
250      if (-f $sectionFileName) {      if (-f $sectionFileName) {
251          # It's there. Get the list from it.          # It's there. Get the list from it.
252          @retVal = Tracer::GetFile($sectionFileName);          @retVal = Tracer::GetFile($sectionFileName);
253      } else {      } else {
254          # We need to create it. First, we get the list: all the complete          # We need to create it. First, we get the list of all complete
255          # genomes followed by a global section indicator. The genomes are sorted          # genomes. As a safety feature, we only include genomes with
256          # in lexical order.          # an organism directory.
257          @retVal = sort { $a cmp $b } $fig->genomes(1);          my @genomes = grep { -d "$FIG_Config::organisms/$_" } $fig->genomes(1);
258            # Sort the results and add the GLOBAL tag.
259            @retVal = sort { $a cmp $b } @genomes;
260          push @retVal, GLOBAL;          push @retVal, GLOBAL;
261          # Write the list to a file for future use. This insures that if the source          # Write the list to a file for future use. This insures that if the source
262          # data changes, we have a consistent section list.          # data changes, we have a consistent section list.

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3