[Bio] / FigKernelScripts / TransactFeatures.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/TransactFeatures.pl

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

revision 1.1, Mon Aug 8 20:13:08 2005 UTC revision 1.2, Tue Aug 9 00:57:48 2005 UTC
# Line 135  Line 135 
135  Numeric trace level. A higher trace level causes more messages to appear. The  Numeric trace level. A higher trace level causes more messages to appear. The
136  default trace level is 3.  default trace level is 3.
137    
138    =item safe
139    
140    Wrap each organism's processing in a database transaction. This makes the process
141    slightly more restartable than it would be otherwise.
142    
143  =cut  =cut
144    
145  use strict;  use strict;
# Line 148  Line 153 
153  use Stats;  use Stats;
154    
155  # Get the command-line options.  # Get the command-line options.
156  my ($options, @parameters) = Tracer::ParseCommand({ trace => 3 }, @ARGV);  my ($options, @parameters) = Tracer::ParseCommand({ trace => 3, safe => 0 }, @ARGV);
157  # Set up tracing.  # Set up tracing.
158  my $traceLevel = $options->{trace};  my $traceLevel = $options->{trace};
159  TSetup("$traceLevel Tracer DocUtils FIG", "TEXT");  TSetup("$traceLevel Tracer DocUtils FIG", "TEXT");
160  # Get the FIG object.  # Get the FIG object.
161  my $fig = FIG->new();  my $fig = FIG->new();
162    # Get its database handle.
163    my $dbh = $fig->db_handle;
164  # Get the command.  # Get the command.
165  my $mainCommand = lc shift @parameters;  my $mainCommand = lc shift @parameters;
166  Trace("$mainCommand command specified.") if T(2);  Trace("$mainCommand command specified.") if T(2);
# Line 211  Line 218 
218              Open(\*TRANS, "<$orgFileName");              Open(\*TRANS, "<$orgFileName");
219              my $tranCount = 0;              my $tranCount = 0;
220              # If we're processing rather than counting, open a file for              # If we're processing rather than counting, open a file for
221              # writing out corrected transactions.              # writing out corrected transactions and optionally start a
222                # database transaction.
223              if ($mainCommand eq 'process') {              if ($mainCommand eq 'process') {
224                  Open(\*TRANSOUT, ">$orgFileName.tbl");                  Open(\*TRANSOUT, ">$orgFileName.tbl");
225                    if ($options->{safe}) {
226                        $dbh->begin_tran();
227                    }
228              }              }
229              # Loop through the organism's data.              # Loop through the organism's data.
230              while (my $transaction = <TRANS>) {              while (my $transaction = <TRANS>) {
# Line 240  Line 251 
251              # Merge the statistics for this run into the globals statistics object.              # Merge the statistics for this run into the globals statistics object.
252              $stats->Accumulate($orgStats);              $stats->Accumulate($orgStats);
253              $stats->Add("genomes", 1);              $stats->Add("genomes", 1);
254              # Close the transaction files.              # Close the transaction input file.
255              close TRANS;              close TRANS;
256                # If we're processing, close the transaction output file
257                # and optionally end the database transaction.
258              if ($mainCommand eq 'process') {              if ($mainCommand eq 'process') {
259                  close TRANSOUT;                  close TRANSOUT;
260                    if ($options->{safe}) {
261                        $dbh->commit_tran();
262                    }
263              }              }
264          }          }
265      }      }
# Line 401  Line 417 
417          for my $annotation (@annotations) {          for my $annotation (@annotations) {
418              my ($oldID, $timestamp, $user, $annotation) = @{$annotation};              my ($oldID, $timestamp, $user, $annotation) = @{$annotation};
419              $fig->add_annotation($realID, $user, $annotation, $timestamp);              $fig->add_annotation($realID, $user, $annotation, $timestamp);
             $controlBlock->{stats}->Add("annotation", 1);  
420              $annotateCount++;              $annotateCount++;
421          }          }
422          # Mark the old feature for deletion.          # Mark the old feature for deletion.
423          $fig->delete_feature($fid);          $fig->delete_feature($fid);
424          # Tell the user what we did.          # Tell the user what we did.
425          $controlBlock->{stat}->Add("assignments", $assignCount);          $controlBlock->{stats}->Add("assignments", $assignCount);
426          $controlBlock->{stat}->Add("annotations", $annotateCount);          $controlBlock->{stats}->Add("annotations", $annotateCount);
427          Trace("Feature $realID created from $fid. $assignCount assignments and $annotateCount annotations copied.") if T(4);          Trace("Feature $realID created from $fid. $assignCount assignments and $annotateCount annotations copied.") if T(4);
428          # Write a corrected transaction to the transaction output file.          # Write a corrected transaction to the transaction output file.
429          print TRANSOUT "change\t$fid\t$realID\t$locations\t$aliases\t$translation\n";          print TRANSOUT "change\t$fid\t$realID\t$locations\t$aliases\t$translation\n";

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3