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

Diff of /FigKernelPackages/FIG.pm

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

revision 1.706, Wed Jul 9 15:59:57 2008 UTC revision 1.707, Thu Jul 10 19:35:33 2008 UTC
# Line 46  Line 46 
46  use File::Path;  use File::Path;
47  use LWP::UserAgent;  use LWP::UserAgent;
48  use LWP::Simple; # for ncbi connection - get genetic code  use LWP::Simple; # for ncbi connection - get genetic code
49    use Digest::MD5;
50    
51  use DBrtns;  use DBrtns;
52  use Sim;  use Sim;
# Line 4650  Line 4651 
4651  }  }
4652    
4653    
4654  =head3 contig_md5sum  =head3 md5_of_peg
4655    
4656      my $cksum = $fig->md5_of_peg( $peg );      my $cksum = $fig->md5_of_peg( $peg );
4657    
# Line 4681  Line 4682 
4682  sub md5_of_peg {  sub md5_of_peg {
4683      my( $self, $peg ) = @_;      my( $self, $peg ) = @_;
4684      return undef if ! $peg;      return undef if ! $peg;
4685    
4686        #  Try to find it in the DBMS
4687    
4688      my $rdbH = $self->db_handle;      my $rdbH = $self->db_handle;
4689        my $dbms_response = $rdbH->SQL( "SELECT md5 FROM protein_sequence_MD5 WHERE id = '$peg'" );
4690    
4691      my $relational_db_response =      return $dbms_response->[0]->[0] if $dbms_response && @$dbms_response;
4692               $rdbH->SQL( "SELECT md5 FROM protein_sequence_MD5 WHERE id = '$peg'" );  
4693        #  Try to make it from the translation
4694    
4695       ! $relational_db_response ? undef      my $sequence = $self->get_translation( $peg );
4696      : @$relational_db_response ? $relational_db_response->[0]->[0]      return undef if ( ! $sequence );
4697      :                            undef;  
4698        #  Got a sequence, find the md5, save it in the DBMS, and return it
4699    
4700        my $md5 = Digest::MD5::md5_hex( uc $sequence );
4701        $rdbH->SQL( "INSERT INTO protein_sequence_MD5 ( id, md5 ) VALUES ( '$peg', '$md5' )" );
4702    
4703        return $md5;
4704  }  }
4705    
4706    
# Line 20044  Line 20056 
20056    
20057      $sequence ||= "";      $sequence ||= "";
20058      $aliases ||= "";      $aliases ||= "";
     my $aliasesT = $aliases;  
     $aliasesT =~ s/,\s*/\t/g;  
     my @aliases = split(/\t/,$aliasesT);  
20059    
20060      if ( 0 )   # GJO - Debug      if ( 0 )   # GJO - Debug
20061      {      {
# Line 20071  Line 20080 
20080      }      }
20081    
20082      $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");      $self->log_update($user,$genome,$self->genus_species($genome),"Added Feature $fid at $contig\_$beg\_$end");
20083    
20084        my $aliasesT = $aliases;
20085        $aliasesT =~ s/,\s*/\t/g;
20086      &add_tbl_entry( $fid, $location, $aliasesT );      &add_tbl_entry( $fid, $location, $aliasesT );
20087    
20088      if ($sequence)      if ($sequence)
20089      {      {
20090          $self->add_sequence( $fid, $sequence );          $self->add_sequence( $fid, $sequence );
20091      }      }
20092    
20093      if ( ( $type eq "peg" ) and $sequence )      if ( ( $type eq "peg" ) and $sequence )
20094      {      {
20095          $self->enqueue_similarities([$fid]);          $self->enqueue_similarities([$fid]);
20096    
20097            my $md5 = Digest::MD5::md5_hex( uc $sequence );
20098            $dbh->SQL( "INSERT INTO protein_sequence_MD5 ( id, md5 ) VALUES ( '$fid', '$md5' )" );
20099      }      }
20100    
20101      my $rv = $dbh->SQL("INSERT INTO features (id,idN,type,genome,location,contig,minloc,maxloc,aliases)      my $rv = $dbh->SQL("INSERT INTO features (id,idN,type,genome,location,contig,minloc,maxloc,aliases)
20102                        VALUES ('$fid',$fidN,'$type','$genome','$location','$contig',$beg,$end,'$aliases')");                        VALUES ('$fid',$fidN,'$type','$genome','$location','$contig',$beg,$end,'$aliases')");
20103    
20104      if (@aliases > 0)      my @aliases = split( /,\s*/, $aliases );
     {  
20105          my $alias;          my $alias;
20106          foreach $alias (@aliases)      foreach $alias ( grep { /^(NP_|gi\||sp\||tr\||kegg\||uni\|)/ } @aliases )
         {  
             if ($alias =~ /^(NP_|gi\||sp\||tr\||kegg\||uni\|)/)  
20107              {              {
   
20108                  $dbh->SQL("INSERT INTO ext_alias (id,alias,genome)                  $dbh->SQL("INSERT INTO ext_alias (id,alias,genome)
20109                             VALUES ('$fid','$alias','$genome')");                             VALUES ('$fid','$alias','$genome')");
20110              }              }
         }  
     }  
20111    
20112      return $fid;      return $fid;
20113  }  }

Legend:
Removed from v.1.706  
changed lines
  Added in v.1.707

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3