[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.369, Sun Sep 18 14:27:13 2005 UTC revision 1.370, Wed Oct 5 20:34:02 2005 UTC
# Line 491  Line 491 
491          my @tmp = `cut -f1 $FIG_Config::organisms/$genome/Features/peg/tbl`;          my @tmp = `cut -f1 $FIG_Config::organisms/$genome/Features/peg/tbl`;
492          chomp @tmp;          chomp @tmp;
493          &run("cat $FIG_Config::organisms/$genome/Features/peg/fasta >> $FIG_Config::data/Global/nr") if (!$skipnr);          &run("cat $FIG_Config::organisms/$genome/Features/peg/fasta >> $FIG_Config::data/Global/nr") if (!$skipnr);
494          &run("formatdb -i $FIG_Config::data/Global/nr -p T") if (!$skipnr);          # &run("formatdb -i $FIG_Config::data/Global/nr -p T") if (!$skipnr);
495          &enqueue_similarities(\@tmp);          &enqueue_similarities(\@tmp);
496      }      }
497      if ((-s "$FIG_Config::organisms/$genome/assigned_functions") ||      if ((-s "$FIG_Config::organisms/$genome/assigned_functions") ||
# Line 5638  Line 5638 
5638    
5639  sub mapped_prot_ids {  sub mapped_prot_ids {
5640      my($self,$id) = @_;      my($self,$id) = @_;
5641        my $rdbH = $self->db_handle;
5642        my $dbh = $rdbH->{_dbh};
5643    
5644      if ($self->is_deleted_fid($id)) { return () }      if ($self->is_deleted_fid($id)) { return () }
5645    
5646      my $rdbH = $self->db_handle;      #
5647      my $relational_db_response = $rdbH->SQL("SELECT maps_to FROM peg_synonyms WHERE  syn_id = \'$id\' ");      # Manage cached statement handles to accelerate multiple queries into the db.
5648        #
5649        my $query_cache = $self->cached("_mapped_prot_ids_cache");
5650        if (not exists($query_cache->{q1}))
5651        {
5652            print "create new q1\n";
5653            $query_cache->{q1} = $dbh->prepare(qq(SELECT maps_to
5654                                                  FROM peg_synonyms
5655                                                  WHERE syn_id = ?));
5656        }
5657        if (not exists($query_cache->{q2}))
5658        {
5659            print "create new q2\n";
5660            $query_cache->{q2} = $dbh->prepare(qq(SELECT syn_id,syn_ln,maps_to_ln
5661                                                  FROM peg_synonyms
5662                                                  WHERE maps_to = ?));
5663        }
5664    
5665        my $q1_sth = $query_cache->{q1};
5666        my $q2_sth = $query_cache->{q2};
5667    
5668        #
5669        # Determine the principal synonym for $id.
5670        #
5671    
5672        $q1_sth->execute($id);
5673        my $relational_db_response = $q1_sth->fetchall_arrayref();
5674    #    my $relational_db_response = $rdbH->SQL("SELECT maps_to FROM peg_synonyms WHERE  syn_id = \'$id\' ");
5675    
5676      if ($relational_db_response && (@$relational_db_response == 1))      if ($relational_db_response && (@$relational_db_response == 1))
5677      {      {
5678          $id = $relational_db_response->[0]->[0];          $id = $relational_db_response->[0]->[0];
5679      }      }
5680    
5681      $relational_db_response = $rdbH->SQL("SELECT syn_id,syn_ln,maps_to_ln FROM peg_synonyms WHERE maps_to = \'$id\' ");      #
5682        # Retrieve the list of synonyms for the principal synonym.
5683        #
5684    
5685        $q2_sth->execute($id);
5686        $relational_db_response = $q2_sth->fetchall_arrayref();
5687    
5688    #    $relational_db_response = $rdbH->SQL("SELECT syn_id,syn_ln,maps_to_ln FROM peg_synonyms WHERE maps_to = \'$id\' ");
5689      if ($relational_db_response && (@$relational_db_response > 0))      if ($relational_db_response && (@$relational_db_response > 0))
5690      {      {
5691          return ([$id,$relational_db_response->[0]->[2]],map { [$_->[0],$_->[1]] } @$relational_db_response);          return ([$id,$relational_db_response->[0]->[2]],map { [$_->[0],$_->[1]] } @$relational_db_response);
5692      }      }
5693      else      else
5694      {      {
5695            #
5696            # If the sequence is a singleton, return it as such.
5697            #
5698    
5699          my $len = $self->translation_length($id);          my $len = $self->translation_length($id);
5700          if ($len)          if ($len)
5701          {          {
# Line 6019  Line 6060 
6060    
6061      return () if $self->is_deleted_fid( $id );      return () if $self->is_deleted_fid( $id );
6062    
6063        #
6064        # Retrieve the list of synonyms for this peg. The first in the list
6065        # is the principal synonym.
6066        #
6067      my @maps_to = $self->mapped_prot_ids( $id );      my @maps_to = $self->mapped_prot_ids( $id );
6068      ( @maps_to > 0 ) or return ();      ( @maps_to > 0 ) or return ();
6069    
# Line 6029  Line 6074 
6074          confess "bad";          confess "bad";
6075      }      }
6076    
6077        #
6078        # Find my entry in the list.
6079        #
6080      my @entry = grep { $_->[0] eq $id } @maps_to;      my @entry = grep { $_->[0] eq $id } @maps_to;
6081      ( @entry == 1 ) and defined( $entry[0]->[1] ) or return ();      ( @entry == 1 ) and defined( $entry[0]->[1] ) or return ();
6082    
6083      #  Get the similarities      #
6084        #  Get the similarities. They are based on the principal synonym.
6085        #
6086    
6087      my @raw_sims = get_raw_sims( $self, $rep_id, $maxP, $filters );      my @raw_sims = get_raw_sims( $self, $rep_id, $maxP, $filters );
6088    
# Line 6130  Line 6180 
6180              my @relevant = ();              my @relevant = ();
6181              $max_expand--;              $max_expand--;
6182    
6183                #
6184                # If we are expanding, determine the set of proteins that
6185                # are equivalent to the protein that we are similar to.
6186                #
6187                # Depending on the options passed in, we filter the
6188                # equivalent proteins found.
6189                #
6190    
6191    
6192              my @maps_to = $self->mapped_prot_ids( $id2 );              my @maps_to = $self->mapped_prot_ids( $id2 );
6193              if ( $select =~ /^figx?$/ )          # Only fig              if ( $select =~ /^figx?$/ )          # Only fig
6194              {              {
# Line 6138  Line 6197 
6197              elsif ( $select =~ /^figx?_?pref/ )  # FIG preferred              elsif ( $select =~ /^figx?_?pref/ )  # FIG preferred
6198              {              {
6199                  @relevant = grep { $_->[0] =~ /^fig/ } @maps_to;                  @relevant = grep { $_->[0] =~ /^fig/ } @maps_to;
6200                  if ( ! @relevant )                  if ( ! @relevant and $id2 !~ /^xxx\d+$/)
6201                  {                  {
6202                      push @sims, $sim;                      push @sims, $sim;
6203                      return @sims if ( @sims >= $maxN );                      return @sims if ( @sims >= $maxN );
# Line 6154  Line 6213 
6213                  @relevant = @maps_to;                  @relevant = @maps_to;
6214              }              }
6215    
6216                #
6217                # Include the relevant sims.
6218                #
6219    
6220              foreach $x ( @relevant )              foreach $x ( @relevant )
6221              {              {
6222                  my ( $x_id, $x_ln ) = @$x;                  my ( $x_id, $x_ln ) = @$x;

Legend:
Removed from v.1.369  
changed lines
  Added in v.1.370

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3