[Bio] / Sprout / LoadSproutTables.pl Repository:
ViewVC logotype

Diff of /Sprout/LoadSproutTables.pl

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

revision 1.38, Wed Aug 2 23:51:19 2006 UTC revision 1.48, Tue Sep 9 21:02:10 2008 UTC
# Line 48  Line 48 
48  C<LoadSproutTables> takes a long time to run, so setting the trace level to 3 helps  C<LoadSproutTables> takes a long time to run, so setting the trace level to 3 helps
49  to give you an idea of the progress.  to give you an idea of the progress.
50    
 Once the Sprout database is loaded, B<TestSproutLoad> can be used to verify the load  
 against the FIG data. The end of the trace log file will contain statistics on  
 the errors found. Like C<LoadSproutTables>, C<TestSproutLoad> is a time-consuming  
 script, so you may want to set the trace level to 3 to see visible progress.  
   
     TestSproutLoad -trace=3 [genomeID] ...  
   
 The I<[genomeID]> specifies zero or more IDs of genomes to receive more thorough  
 testing. So, for example,  
   
     TestSproutLoad -trace=3 100226.1 83333.1  
   
 would do thorough testing of I<Streptomyces coelicolor A3-2> (100226.1) and  
 I<Escherichia coli K12> (83333.1).  
   
 Unlike C<LoadSproutTables>, in C<TestSproutLoad>, the individual errors found are  
 mixed in with the trace messages. They are all, however, marked with a trace type  
 of B<Problem>, as shown in the fragment below.  
   
     11/02/2005 19:15:16 <main>: Processing feature fig|100226.1.peg.7742.  
     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7741.  
     11/02/2005 19:15:17 <Problem>: assignment "Short-chain dehydrodenase ...  
     11/02/2005 19:15:17 <Problem>: assignment "putative oxidoreductase." ...  
     11/02/2005 19:15:17 <Problem>: Incorrect assignment for fig|100226.1.peg.7741...  
     11/02/2005 19:15:17 <Problem>: Incorrect number of annotations found in ...  
     11/02/2005 19:15:17 <main>: Processing feature fig|100226.1.peg.7740.  
     11/02/2005 19:15:18 <main>: Processing feature fig|100226.1.peg.7739.  
   
 The test may reveal that some tables need to be reloaded, or that a software  
 problem has crept into the Sprout.  
   
 Once all the tables have the correct data, C<index_sprout_lucene> can be run to create the  
 Lucene search indexes. Lucene is a web site search engine produced by the Apache project.  
 It is written in Java, and in order to run it you must have the B<LuceneSearch> and  
 B<NmpdrConfigs> projects checked out from CVS and made.  
   
51  =head2 The NMPDR Web Site  =head2 The NMPDR Web Site
52    
53  Sprout is the database engine for the NMPDR web site. The NMPDR web site consists of two  Sprout is the database engine for the NMPDR web site. The NMPDR web site consists of two
# Line 140  Line 104 
104    
105  =back  =back
106    
107  =over 4  Most of the above preparation is performed by the B<NMPDRSetup> utility.
108    NMPDRSetup prints the instructions for completing the process, including
109  The procedure for loading Sprout is as follows.  loading the Sprout database. The specific procedure for loading
110    the Sprout data, however, is as follows.
 =item 1  
   
 Type  
   
     nohup LoadSproutTables -dbLoad -dbCreate -user=you -background "*" >null &  
   
 where C<you> is your user ID, and press ENTER. This will create the C<dtx> files  
 and load them. You may be asked for a password. If this is the case, simply  
 press ENTER. If that does not work, use the C<dbpass> value specified in  
 your C<FIG_Config.pm> file.  
   
 The above command line runs the load in the background. The standard output,  
 standard error, and trace output will be directed to files in the FIG temporary  
 directory. If your user name is C<Bruce> then the files will be named  
 C<outBruce.log>, C<errBruce.log>, and C<traceBruce.log> respectively.  
   
 If the load fails at some point and you are able to correct the problem, use the  
 C<resume> option to restart it. For example, if the load failed while doing the  
 Feature load group, you would resume it using  
   
     nohup LoadSproutTables -dbLoad -dbCreate -user=you -resume -background Feature >null &  
   
 =item 2  
   
 Type  
   
     nohup TestSproutLoad -user=you -background >null &100226.1 83333.1>  
   
 and press ENTER. This will validate the Sprout database against the SEED data.  
   
 =item 3  
   
 If any errors are detected in step (2), it is most likely due to a change in  
 SEED that did not make it to Sprout. Contact Bruce Parrello or Robert Olson  
 to get the code updated properly.  
   
 =item 4  
   
 Type  
   
     index_sprout_lucene  
   
  and press ENTER. This will create the Lucene indexes for the Sprout data.  
   
 =item 5  
   
 Change to the B<SproutData/Indexes> directory under B<FIGdisk> and look for the  
 directory created by C<index_sprout_lucene>. The directory name will be  
 something like C<Lucene.20060412-154112>. The numbers indicate the date and time  
 the index was created. In this case it was 04/12/2006 03:41:12pm. Type  
   
     ln -sf directory Lucene  
   
 where C<directory> is the new directory name, to point the C<Lucene> directory to the  
 new search index.  
   
 =back  
111    
112  =head2 LoadSproutTables Command  =head2 LoadSproutTables Command
113    
# Line 217  Line 124 
124  =item Feature  =item Feature
125    
126  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,  Loads B<Feature>, B<FeatureAlias>, B<FeatureTranslation>, B<FeatureUpstream>,
127  B<IsLocatedIn>, B<FeatureLink>.  B<IsLocatedIn>, B<FeatureLink>, B<IsAliasOf>, B<CDD>, B<HasFeature>,
128    B<HasRoleInSubsystem>, B<FeatureEssential>, B<FeatureVirulent>, B<FeatureIEDB>,
129  =item Coupling  B<CDD>, and B<IsPresentOnProteinOf>
   
 Loads B<Coupling>, B<IsEvidencedBy>, B<PCH>, B<ParticipatesInCoupling>,  
 B<UsesAsEvidence>.  
130    
131  =item Subsystem  =item Subsystem
132    
133  Loads B<Subsystem>, B<Role>, B<SSCell>, B<ContainsFeature>, B<IsGenomeOf>,  Loads B<Subsystem>, B<Role>, B<SSCell>, B<ContainsFeature>, B<IsGenomeOf>,
134  B<IsRoleOf>, B<OccursInSubsystem>, B<ParticipatesIn>, B<HasSSCell>,  B<IsRoleOf>, B<OccursInSubsystem>, B<ParticipatesIn>, B<HasSSCell>,
135  B<Catalyzes>, B<ConsistsOfRoles>, B<RoleSubset>, B<HasRoleSubset>,  B<ConsistsOfRoles>, B<RoleSubset>, B<HasRoleSubset>,
136  B<ConsistsOfGenomes>, B<GenomeSubset>, B<HasGenomeSubset>, B<Diagram>,  B<ConsistsOfGenomes>, B<GenomeSubset>, B<HasGenomeSubset>, B<Diagram>,
137  B<RoleOccursIn>.  B<RoleOccursIn>, B<SubSystemClass>, B<RoleEC>, B<IsIdentifiedByEC>, and
138    B<ContainsFeature>.
139    
140  =item Annotation  =item Annotation
141    
142  Loads B<SproutUser>, B<UserAccess>, B<Annotation>, B<IsTargetOfAnnotation>,  Loads B<SproutUser>, B<UserAccess>, B<Annotation>, B<IsTargetOfAnnotation>, and
143  B<MadeAnnotation>.  B<MadeAnnotation>.
144    
145  =item Property  =item Property
146    
147  Loads B<Property>, B<HasProperty>.  Loads B<Property>, and B<HasProperty>.
   
 =item BBH  
   
 Loads B<IsBidirectionalBestHitOf>.  
148    
149  =item Group  =item Group
150    
# Line 251  Line 152 
152    
153  =item Source  =item Source
154    
155  Loads B<Source>, B<ComesFrom>, B<SourceURL>.  Loads B<Source>, B<ComesFrom>, and B<SourceURL>.
   
 =item External  
   
 Loads B<ExternalAliasOrg>, B<ExternalAliasFunc>.  
156    
157  =item Reaction  =item Reaction
158    
159  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,  Loads B<ReactionURL>, B<Compound>, B<CompoundName>,
160  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>.  B<CompoundCAS>, B<IsAComponentOf>, B<Reaction>, B<Scenario>, B<IsInputFor>,
161    B<IsOutputOf>, B<IsOnDiagram>, and B<Catalyzes>.
162    
163  =item Synonym  =item Synonym
164    
# Line 270  Line 168 
168    
169  Loads B<Family> and B<IsFamilyForFeature>.  Loads B<Family> and B<IsFamilyForFeature>.
170    
171    =item Drug
172    
173    Loads B<PDB>, B<DocksWith>, C<IsProteinForFeature>, and C<Ligand>.
174    
175  =item *  =item *
176    
177  Loads all of the above tables.  Loads all of the above tables.
# Line 285  Line 187 
187  The name of the file containing the genomes and their associated access codes. The  The name of the file containing the genomes and their associated access codes. The
188  file should have one line per genome, each line consisting of the genome ID followed  file should have one line per genome, each line consisting of the genome ID followed
189  by the access code, separated by a tab. If no file is specified, all complete genomes  by the access code, separated by a tab. If no file is specified, all complete genomes
190  will be processed and the access code will be 1.  will be processed and the access code will be 1. Specify C<default> to use the
191    default gene file-- C<genes.tbl> in the C<SproutData> directory.
192    
193  =item subsysFile  =item subsysFile
194    
# Line 315  Line 218 
218  will not be created. This option is useful if you are setting up a copy of Sprout  will not be created. This option is useful if you are setting up a copy of Sprout
219  and have load files already set up from the original version.  and have load files already set up from the original version.
220    
 =item primaryOnly  
   
 If TRUE, only the group's primary entity will be loaded.  
   
221  =item background  =item background
222    
223  Redirect the standard and error output to files in the FIG temporary directory.  Redirect the standard and error output to files in the FIG temporary directory.
# Line 342  Line 241 
241    
242  use strict;  use strict;
243  use Tracer;  use Tracer;
 use DocUtils;  
244  use Cwd;  use Cwd;
245  use FIG;  use FIG;
246  use SFXlate;  use SFXlate;
# Line 352  Line 250 
250  use Stats;  use Stats;
251  use SFXlate;  use SFXlate;
252    
253    # This is a list of the load groups in their natural order. We'll go through these in sequence, processing
254    # the ones the user asks for.
255    my @LoadGroups = qw(Genome Subsystem Property Annotation Source Reaction Synonym Family Drug Feature);
256    
257  # Get the command-line parameters and options.  # Get the command-line parameters and options.
258  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',  my ($options, @parameters) = StandardSetup(['SproutLoad', 'ERDBLoad', 'Stats',
259                                              'ERDB', 'Load', 'Sprout', 'Subsystem'],                                              'ERDB', 'Load', 'Sprout', 'Subsystem'],
# Line 360  Line 262 
262                                                dbLoad => [0, "load the database from generated files"],                                                dbLoad => [0, "load the database from generated files"],
263                                                dbCreate => [0, "drop and re-create the database"],                                                dbCreate => [0, "drop and re-create the database"],
264                                                loadOnly => [0, "load the database from previously generated files"],                                                loadOnly => [0, "load the database from previously generated files"],
                                               primaryOnly => [0, "only process the group's main entity"],  
265                                                resume => [0, "resume a complete load starting with the first group specified in the parameter list"],                                                resume => [0, "resume a complete load starting with the first group specified in the parameter list"],
266                                                phone => ["", "phone number (international format) to call when load finishes"],                                                phone => ["", "phone number (international format) to call when load finishes"],
267                                              },                                              },
# Line 375  Line 276 
276      my $db = $FIG_Config::sproutDB;      my $db = $FIG_Config::sproutDB;
277      DBKernel::CreateDB($db);      DBKernel::CreateDB($db);
278  }  }
279    # Compute the gene file name.
280    my $geneFile = $options->{geneFile};
281    if ($geneFile eq 'default') {
282        $geneFile = "$FIG_Config::sproutData/genes.tbl";
283    }
284  # Create the sprout loader object. Note that the Sprout object does not  # Create the sprout loader object. Note that the Sprout object does not
285  # open the database unless the "dbLoad" option is turned on.  # open the database unless the "dbLoad" option is turned on.
286  my $fig = FIG->new();  my $fig = FIG->new();
287  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});  my $sprout = SFXlate->new_sprout_only(undef, undef, undef, ! $options->{dbLoad});
288  my $spl = SproutLoad->new($sprout, $fig, $options->{geneFile}, $options->{subsysFile}, $options);  my $spl = SproutLoad->new($sprout, $fig, $geneFile, $options->{subsysFile}, $options);
289  # Insure we have an output directory.  # Insure we have an output directory.
290  FIG::verify_dir($FIG_Config::sproutData);  FIG::verify_dir($FIG_Config::sproutData);
291    # Check for the "*" option.
292    if ($parameters[0] eq '*') {
293        @parameters = @LoadGroups;
294    }
295  # If we're resuming, we only want to have 1 parameter.  # If we're resuming, we only want to have 1 parameter.
296  my $resume = $options->{resume};  my $resume = $options->{resume};
297  if ($resume && @parameters > 1) {  if ($resume && @parameters > 1) {
# Line 389  Line 299 
299  } elsif (! @parameters) {  } elsif (! @parameters) {
300      Trace("No load groups were specified.") if T(0);      Trace("No load groups were specified.") if T(0);
301  }  }
302    # Process the resume option here. We modify the incoming parameters to
303    # contain the resume group and everything after it.
304    if ($resume) {
305        # Save the starting group.
306        my $resumeGroup = $parameters[0];
307        # Copy the load group list into the parameter array.
308        @parameters = @LoadGroups;
309        # Shift out the groups until we reach our desired starting point.
310        while (scalar(@parameters) && $parameters[0] ne $resumeGroup) {
311            shift @parameters;
312        }
313        if (! @parameters) {
314            Confess("Resume group \"$resumeGroup\" not found.");
315        }
316    }
317  # Set a variable to contain return type information.  # Set a variable to contain return type information.
318  my $rtype;  my $rtype;
319    # Set up a statistics object for statistics about the entire load.
320    my $totalStats = Stats->new();
321  # Insure we catch errors.  # Insure we catch errors.
322  eval {  eval {
323      # Process the parameters.      # Process the parameters.
324      for my $group (@parameters) {      for my $group (@parameters) {
325          Trace("Processing load group $group.") if T(2);          Trace("Processing load group $group.") if T(2);
326          my $stats;          # Compute the string we want to execute.
327          if ($group eq 'Genome' || $group eq '*') {          my $code = "\$spl->Load${group}Data()";
328              $spl->LoadGenomeData();          # Load this group.
329              $group = ResumeCheck($resume, $group);          my $stats = eval($code);
330          }          if ($@) {
331          if ($group eq 'Feature' || $group eq '*') {              Confess("Load group error: $@");
332              $spl->LoadFeatureData();          }
333              $group = ResumeCheck($resume, $group);          # Merge the statistics into the master.
334          }          $totalStats->Accumulate($stats);
         if ($group eq 'Coupling' || $group eq '*') {  
             $spl->LoadCouplingData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Subsystem' || $group eq '*') {  
             $spl->LoadSubsystemData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Property' || $group eq '*') {  
             $spl->LoadPropertyData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Annotation' || $group eq '*') {  
             $spl->LoadAnnotationData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'BBH' || $group eq '*') {  
             $spl->LoadBBHData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Group' || $group eq '*') {  
             $spl->LoadGroupData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Source' || $group eq '*') {  
             $spl->LoadSourceData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'External' || $group eq '*') {  
             $spl->LoadExternalData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Reaction' || $group eq '*') {  
             $spl->LoadReactionData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Synonym' || $group eq '*') {  
             $spl->LoadSynonymData();  
             $group = ResumeCheck($resume, $group);  
         }  
         if ($group eq 'Family' || $group eq '*') {  
             $spl->LoadFamilyData();  
             $group = ResumeCheck($resume, $group);  
335          }          }
336        # Compute the statistical display.
337        my $statDisplay = $totalStats->Show();
338        # Display it.
339        Trace("Statistics for this load:\n$statDisplay") if T(2);
340        # Check for a "table load failed" message. If we find one, we want
341        # to end with an error.
342        if ($statDisplay =~ /table load failed/i) {
343            Confess("One or more table loads failed.");
344      }      }
345  };  };
346  if ($@) {  if ($@) {
# Line 467  Line 359 
359      }      }
360  }  }
361    
 # If the resume flag is set, return "*", else return "".  
 sub ResumeCheck {  
     my ($resume, $group) = @_;  
     return ($resume ? "*" : $group);  
 }  
   
362  1;  1;

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.48

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3