[Bio] / FigKernelPackages / ServerThing.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/ServerThing.pm

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

revision 1.40, Tue Mar 16 20:24:05 2010 UTC revision 1.45, Fri Mar 19 18:27:07 2010 UTC
# Line 468  Line 468 
468      my $testFileName = "$FIG_Config::organisms/$genomeA/CorrToReferenceGenomes/$genomeB";      my $testFileName = "$FIG_Config::organisms/$genomeA/CorrToReferenceGenomes/$genomeB";
469      if (0 && -f $testFileName) {      if (0 && -f $testFileName) {
470          # Use the pre-computed file.          # Use the pre-computed file.
471          Trace("Using pre-computed file $fileName for genome correspondence.") if T(3);          Trace("Using pre-computed file $fileName for genome correspondence.") if T(Corr => 3);
472          $fileName = $testFileName;          $fileName = $testFileName;
473      } elsif (-f $corrFileName) {      } elsif (-f $corrFileName) {
474          $fileName = $corrFileName;          $fileName = $corrFileName;
475          Trace("Using cached file $fileName for genome correspondence.") if T(3);          Trace("Using cached file $fileName for genome correspondence.") if T(Corr => 3);
476      }      }
477      # Return the result.      # Return the result.
478      return ($fileName, $converse);      return ($fileName, $converse);
# Line 513  Line 513 
513      # Declare the return variables.      # Declare the return variables.
514      my ($fileName, $genomeA, $genomeB);      my ($fileName, $genomeA, $genomeB);
515      # Determine the ordering of the genome IDs.      # Determine the ordering of the genome IDs.
516      if ($genome1 lt $genome2) {      if (MustFlipGenomeIDs($genome1, $genome2)) {
         ($genomeA, $genomeB) = ($genome1, $genome2);  
     } else {  
517          ($genomeA, $genomeB) = ($genome2, $genome1);          ($genomeA, $genomeB) = ($genome2, $genome1);
518        } else {
519            ($genomeA, $genomeB) = ($genome1, $genome2);
520      }      }
521      # Insure the source organism has a subdirectory in the organism cache.      # Insure the source organism has a subdirectory in the organism cache.
522      my $orgDir = "$FIG_Config::orgCache/$genomeA";      my $orgDir = "$FIG_Config::orgCache/$genomeA";
# Line 599  Line 599 
599              # Everything is ok, fix the permissions and return the file name.              # Everything is ok, fix the permissions and return the file name.
600              chmod 0664, $corrFileName;              chmod 0664, $corrFileName;
601              $fileName = $corrFileName;              $fileName = $corrFileName;
602              Trace("Created correspondence file $fileName.") if T(3);              Trace("Created correspondence file $fileName.") if T(Corr => 3);
603          }          }
604      }      }
605      # If the temporary file exists, delete it.      # If the temporary file exists, delete it.
# Line 611  Line 611 
611  }  }
612    
613    
614    =head3 MustFlipGenomeIDs
615    
616        my $converse = ServerThing::MustFlipGenomeIDs($genome1, $genome2);
617    
618    Return TRUE if the specified genome IDs are out of order. When genome IDs are out of
619    order, they are stored in the converse order in correspondence files on the server.
620    This is a simple method that allows the caller to check for the need to flip.
621    
622    =over 4
623    
624    =item genome1
625    
626    ID of the proposed source genome.
627    
628    =item genome2
629    
630    ID of the proposed target genome.
631    
632    =item RETURN
633    
634    Returns TRUE if the first genome would be stored on the server as a target, FALSE if
635    it would be stored as a source.
636    
637    =cut
638    
639    sub MustFlipGenomeIDs {
640        # Get the parameters.
641        my ($genome1, $genome2) = @_;
642        # Return an indication.
643        return ($genome1 gt $genome2);
644    }
645    
646    
647  =head3 ReadGeneCorrespondenceFile  =head3 ReadGeneCorrespondenceFile
648    
649      my $list = ServerThing::ReadGeneCorrespondenceFile($fileName, $converse, $all);      my $list = ServerThing::ReadGeneCorrespondenceFile($fileName, $converse, $all);
# Line 662  Line 695 
695      Trace("Reading correspondence file $fileName.") if T(3);      Trace("Reading correspondence file $fileName.") if T(3);
696      if (! open $ih, "<$fileName") {      if (! open $ih, "<$fileName") {
697          # Here the open failed, so we have an error.          # Here the open failed, so we have an error.
698          Trace("Failed to open gene correspondence file $fileName: $!") if T(3);          Trace("Failed to open gene correspondence file $fileName: $!") if T(Corr => 1);
699          $error = 1;          $error = 1;
700      }      }
701      # The gene correspondence list will be built in here.      # The gene correspondence list will be built in here.
# Line 683  Line 716 
716          }          }
717          # Validate the row.          # Validate the row.
718          if (ValidateGeneCorrespondenceRow(\@row)) {          if (ValidateGeneCorrespondenceRow(\@row)) {
719              Trace("Invalid row $. found in correspondence file $fileName.") if T(3);              Trace("Invalid row $. found in correspondence file $fileName.") if T(Corr => 1);
720              $error = 1;              $error = 1;
721          }          }
722          # If this row is in the correct direction, keep it.          # If this row is in the correct direction, keep it.
# Line 698  Line 731 
731          if ($reverseFound) {          if ($reverseFound) {
732              $retVal = \@corrList;              $retVal = \@corrList;
733          } else {          } else {
734              Trace("No reverse arrow found in correspondence file $fileName.") if T(3);              Trace("No reverse arrow found in correspondence file $fileName.") if T(Corr => 1);
735          }          }
736      }      }
737      # Return the result (if any).      # Return the result (if any).
# Line 728  Line 761 
761      my ($row) = @_;      my ($row) = @_;
762      # Flip the row in place.      # Flip the row in place.
763      ($row->[1], $row->[0], $row->[2], $row->[3], $row->[5], $row->[4], $row->[7],      ($row->[1], $row->[0], $row->[2], $row->[3], $row->[5], $row->[4], $row->[7],
764       $row->[6], ARROW_FLIP->{$row->[8]}, $row->[9], $row->[10], $row->[14],       $row->[6], $row->[8], $row->[9], $row->[10], $row->[14],
765       $row->[15], $row->[16], $row->[11], $row->[12], $row->[13], $row->[17]) = @$row;       $row->[15], $row->[16], $row->[11], $row->[12], $row->[13], $row->[17]) = @$row;
766        # Flip the arrow.
767        $row->[8] = ARROW_FLIP->{$row->[8]};
768        # Flip the pairs.
769        my @elements = split /,/, $row->[3];
770        $row->[3] = join(",", map { join(":", reverse split /:/, $_) } @elements);
771  }  }
772    
773  =head3 ValidateGeneCorrespondenceRow  =head3 ValidateGeneCorrespondenceRow
# Line 763  Line 801 
801      # Check for non-numeric values in the number columns.      # Check for non-numeric values in the number columns.
802      for my $col (@{NUM_COLS()}) {      for my $col (@{NUM_COLS()}) {
803          unless ($row->[$col] =~ /^-?\d+\.?\d*(?:e[+-]?\d+)?$/) {          unless ($row->[$col] =~ /^-?\d+\.?\d*(?:e[+-]?\d+)?$/) {
804                Trace("Gene correspondence error. \"$row->[$col]\" not numeric.") if T(Corr => 2);
805              $retVal++;              $retVal++;
806          }          }
807      }      }
808      # Check the gene IDs.      # Check the gene IDs.
809      for my $col (0, 1) {      for my $col (0, 1) {
810          unless ($row->[$col] =~ /^fig\|\d+\.\d+\.\w+\.\d+$/) {          unless ($row->[$col] =~ /^fig\|\d+\.\d+\.\w+\.\d+$/) {
811                Trace("Gene correspondence error. \"$row->[$col]\" not a gene ID.") if T(Corr => 2);
812              $retVal++;              $retVal++;
813          }          }
814      }      }
815      # Verify the arrow.      # Verify the arrow.
816      unless (exists ARROW_FLIP->{$row->[8]}) {      unless (exists ARROW_FLIP->{$row->[8]}) {
817            Trace("Gene correspondence error. \"$row->[8]\" not an arrow.") if T(Corr => 2);
818          $retVal++;          $retVal++;
819      }      }
820      # Return the error count.      # Return the error count.

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.45

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3