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

Diff of /Sprout/EvCodeRefresh.pl

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

revision 1.3, Fri Jul 11 01:05:46 2008 UTC revision 1.4, Tue Aug 12 06:06:02 2008 UTC
# Line 44  Line 44 
44    
45  =item load  =item load
46    
47  Specifies a file containing evidence codes. The file should contain either 2 or 3  Specifies a file containing evidence codes. The file should contain 3
48  columns. Each record should contain a feature ID in the first column and a  columns. Each record should contain a feature ID in the first column, the
49  corresponding evidence code in the last column. If this option is specified,  literal C<evidence_code> in the middle column, and a corresponding evidence code
50  the evidence codes are loaded from the file. Otherwise, the evidence codes are  in the last column. If this option is specified, the evidence codes are loaded
51  recomputed into a new temporary file.  from the file. Otherwise, the evidence codes are recomputed into a new temporary file.
   
 =item classes  
   
 If this option is specified, it should be the name of a tab-delimited file  
 containing the evidence classes. The evidence class table will be deleted and  
 reloaded from the file, which should be a valid ERDB load file for the  
 B<EvidenceClass> table.  
52    
53  =item user  =item user
54    
# Line 93  Line 86 
86                                             {                                             {
87                                                load => ["", "file containing evidence codes; if none specified, evidence codes will be computed"],                                                load => ["", "file containing evidence codes; if none specified, evidence codes will be computed"],
88                                                trace => ["2", "tracing level"],                                                trace => ["2", "tracing level"],
                                               classes => ["", "evidence class file name"],  
89                                                phone => ["", "phone number (international format) to call when load finishes"]                                                phone => ["", "phone number (international format) to call when load finishes"]
90                                             },                                             },
91                                             "",                                             "",
# Line 136  Line 128 
128      }      }
129      # Now we're ready to load. Get the attributes database.      # Now we're ready to load. Get the attributes database.
130      my $attr = CustomAttributes->new();      my $attr = CustomAttributes->new();
131      # Check for a class file.      # Load it.
     if ($options->{classes}) {  
         # We have one. Load it into the evidence class table.  
         Trace("Loading evidence classes from $options->{classes}.") if T(2);  
         $attr->LoadTable($options->{classes}, 'EvidenceClass', truncate => 1);  
         Trace("Evidence classes loaded.") if T(2);  
     }  
     # Now we convert the evidence code file into a load file for the IsEvidencedBy  
     # table. First, we open it.  
     my $ih = Open(undef, "<$fileName");  
     # Create the load file. We sort it to speed up the load.  
     my $loadFileName = "$FIG_Config::temp/IsEvidencedBy$$.dtx";  
     my $oh = Open(undef, "| sort >$loadFileName");  
     # Finally, we use this hash to track all the evidence classes.  
     my %classes = ();  
     Trace("Reading evidence codes.") if T(3);  
     # Loop through the input file, writing load records.  
     while (! eof $ih) {  
         # Read the input record.  
         my @fields = Tracer::GetLine($ih);  
         my $line = $.;  
         Trace("$line input lines processed.") if T(3) && ($. % 10000 == 0);  
         # Insure it's valid.  
         my $last = $#fields;  
         if ($last >= 3 || $last < 1) {  
             Trace("Record $line in input file has incorrect number of columns.") if T(3);  
             $stats->Add(errors => 1);  
         } else {  
             # Get the feature ID and the code.  
             my ($fid, $code) = @fields[0, $last];  
             # Validate the feature ID and the evidence code.  
             if (! ($fid =~ /^fig\|\d+/)) {  
                 Trace("Record $line in input file has invalid feature ID \"$fid\".") if T(3);  
                 $stats->Add(errors => 1);  
             } elsif (! ($code =~ /^([a-z]+)(.*)/)) {  
                 Trace("Record $line in input file has invalid evidence code \"$code\".") if T(3);  
                 $stats->Add(errors => 1);  
             } else {  
                 # We have a valid input row. Produce the output line. Note that as a  
                 # result of the pattern match that validated the evidence code, $1  
                 # contains the class and $2 the modifier.  
                 my ($class, $modifier) = ($1, $2);  
                 Tracer::PutLine($oh, [$fid, $class, $modifier]);  
                 # Count this as an output row and as a member of the specified class.  
                 $stats->Add(rows => 1);  
                 $stats->Add($class => 1);  
                 $classes{$class} = 1;  
             }  
         }  
     }  
     Trace("Evidence codes reformatted.") if T(2);  
     # Close the files.  
     close $oh;  
     close $ih;  
     Trace("Evidence codes will be loaded from $loadFileName.") if T(2);  
     # Now we need to verify the incoming evidence codes against the known  
     # evidence classes. We issue a message for every non-existent class. It's  
     # not a serious error, but it's something the user should know.  
     Trace("Verifying evidence classes.") if T(2);  
     for my $class (keys %classes) {  
         if (! $attr->Exists(EvidenceClass => $class)) {  
             Trace("Evidence class \"$class\" not found in database!") if T(2);  
             $stats->Add(bad_class => 1);  
         }  
     }  
     # Now we load.  
132      Trace("Loading evidence codes.") if T(2);      Trace("Loading evidence codes.") if T(2);
133      $attr->LoadTable($loadFileName, 'IsEvidencedBy', truncate => 1,      $attr->LoadAttributesFrom($fileName, mode => 'concurrent');
                      mode => 'concurrent');  
134      # Tell the user we're done, and show the statistics.      # Tell the user we're done, and show the statistics.
135      Trace("Evidence codes loaded.\n" . $stats->Show()) if T(2);      Trace("Evidence codes loaded.\n" . $stats->Show()) if T(2);
136  };  };
# Line 343  Line 269 
269                  for my $peg (keys(%pegs_in_row)) {                  for my $peg (keys(%pegs_in_row)) {
270                      # If this peg has ISU evidence, send it to the output.                      # If this peg has ISU evidence, send it to the output.
271                      if ($isu{$peg} ) {                      if ($isu{$peg} ) {
272                          Tracer::PutLine($oh, [$peg, '', "isu;$sub"]);                          Tracer::PutLine($oh, [$peg, 'evidence_code', "isu;$sub"]);
273                      }                      }
274                      # If this peg has ICW evidence, send it to the output.                      # If this peg has ICW evidence, send it to the output.
275                      if (my $n = $icw{$peg} ) {                      if (my $n = $icw{$peg} ) {
276                          Tracer::PutLine($oh, [$peg, '', "icw($n);$sub"]);                          Tracer::PutLine($oh, [$peg, 'evidence_code', "icw($n);$sub"]);
277                      } else {                      } else {
278                          # If there's no ICW evidence, ty IDU evidence.                          # If there's no ICW evidence, ty IDU evidence.
279                          if ($n = $isd{$peg} ) {                          if ($n = $isd{$peg} ) {
280                              Tracer::PutLine($oh, [$peg, '', "idu($n);$sub"]);                              Tracer::PutLine($oh, [$peg, 'evidence_code', "idu($n);$sub"]);
281                          }                          }
282                      }                      }
283                  }                  }
# Line 379  Line 305 
305          while (defined($_ = <FF>)) {          while (defined($_ = <FF>)) {
306              # If there is a PEG on this line, denote the PEG has fig-family evidence.              # If there is a PEG on this line, denote the PEG has fig-family evidence.
307              if ($_ =~ /^(fig\|\d+\.\d+\.peg\.\d+)/) {              if ($_ =~ /^(fig\|\d+\.\d+\.peg\.\d+)/) {
308                  Tracer::PutLine($oh, [$1, '', 'ff']);                  Tracer::PutLine($oh, [$1, 'evidence_code', 'ff']);
309              }              }
310          }          }
311          close(FF);          close(FF);
# Line 412  Line 338 
338                  for ($i=0; ($i < @set) && &FIG::hypo(scalar $fig->function_of($set[$i])); $i++) {}                  for ($i=0; ($i < @set) && &FIG::hypo(scalar $fig->function_of($set[$i])); $i++) {}
339                  # If we found a non-hypothetical PEG, we are CWN, else we're CWH.                  # If we found a non-hypothetical PEG, we are CWN, else we're CWH.
340                  if ($i < @set) {                  if ($i < @set) {
341                      Tracer::PutLine($oh, [$curr, '', 'cwn']);                      Tracer::PutLine($oh, [$curr, 'evidence_code', 'cwn']);
342                  } else {                  } else {
343                      Tracer::PutLine($oh, [$curr, '', 'cwh']);                      Tracer::PutLine($oh, [$curr, 'evidence_code', 'cwh']);
344                  }                  }
345              }              }
346          }          }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3