[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.3, Thu Oct 2 16:32:42 2008 UTC revision 1.4, Mon Jan 19 21:46:21 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 base load group object.      # Create the base load group object.
71      my $retVal = ERDBLoadGroup::new($class, $source, $erdb, $options, @tables);      my $retVal = ERDBLoadGroup::new($class, $erdb, $options, @tables);
72      # Return it.      # Return it.
73      return $retVal;      return $retVal;
74  }  }
# Line 91  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 111  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 186  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) && defined $fig->get_subsystem($sub)) {
196                  push @retVal, $sub;                  push @retVal, $sub;
197              }              }
198          }          }
# Line 228  Line 234 
234  =cut  =cut
235    
236  sub GetSectionList {  sub GetSectionList {
237      my ($sprout, $fig) = @_;      my ($sprout) = @_;
238      # Declare the return variable.      # Declare the return variable.
239      my @retVal;      my @retVal;
240        # Get the FIG object.
241        my $fig = FIG->new();
242      # Look for the section list in the data directory.      # Look for the section list in the data directory.
243      my $sectionFileName = $sprout->LoadDirectory() . "/" .      my $sectionFileName = $sprout->LoadDirectory() . "/" .
244          ERDBGenerate::CreateFileName('section_master', undef, 'control');          ERDBGenerate::CreateFileName('section_master', undef, 'control');
# Line 238  Line 246 
246          # It's there. Get the list from it.          # It's there. Get the list from it.
247          @retVal = Tracer::GetFile($sectionFileName);          @retVal = Tracer::GetFile($sectionFileName);
248      } else {      } else {
249          # 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
250          # genomes followed by a global section indicator. The genomes are sorted          # genomes. As a safety feature, we only include genomes with
251          # in lexical order.          # an organism directory.
252          @retVal = sort { $a cmp $b } $fig->genomes(1);          my @genomes = grep { -d "$FIG_Config::organisms/$_" } $fig->genomes(1);
253            # Sort the results and add the GLOBAL tag.
254            @retVal = sort { $a cmp $b } @genomes;
255          push @retVal, GLOBAL;          push @retVal, GLOBAL;
256          # 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
257          # data changes, we have a consistent section list.          # data changes, we have a consistent section list.

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3