[Bioperl-guts-l] bioperl-live/Bio/DB/GFF/Adaptor/dbi mysqlcmap.pm, 1.2, 1.3

Ben faga faga at pub.open-bio.org
Tue Mar 8 22:05:33 EST 2005


Update of /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor/dbi
In directory pub.open-bio.org:/tmp/cvs-serv1638/Bio/DB/GFF/Adaptor/dbi

Modified Files:
	mysqlcmap.pm 
Log Message:
Needed to overwrite another method to get the regular loader to work properly.


Index: mysqlcmap.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/DB/GFF/Adaptor/dbi/mysqlcmap.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** mysqlcmap.pm	1 Mar 2005 22:22:33 -0000	1.2
--- mysqlcmap.pm	9 Mar 2005 03:05:30 -0000	1.3
***************
*** 669,673 ****
    PRIMARY KEY  (table_name)
  ) TYPE=MyISAM;
! } # table
  },
  
--- 669,674 ----
    PRIMARY KEY  (table_name)
  ) TYPE=MyISAM;
! }, # table
! insert=>{next_num=>q[ insert into cmap_next_number (table_name,next_number) VALUES ('cmap_feature',82);]}
  },
  
***************
*** 753,761 ****
    }
  
    my $lookup_type = $dbh->prepare_delayed('SELECT ftypeid FROM ftype WHERE fmethod=? AND fsource=?');
    my $insert_type = $dbh->prepare_delayed('INSERT INTO ftype (fmethod,fsource) VALUES (?,?)');
  
    my $lookup_group = $dbh->prepare_delayed('SELECT feature_id FROM cmap_feature WHERE feature_name=? AND gclass=?');
!   my $insert_group = $dbh->prepare_delayed(' insert into cmap_feature (feature_id, feature_name, gclass )  select next_number , ?,? from cmap_next_number where table_name=\'cmap_feature\';update cmap_next_number set next_number = next_number +1 where table_name=\'cmap_feature\'');
  
    my $lookup_attribute = $dbh->prepare_delayed('SELECT fattribute_id FROM fattribute WHERE fattribute_name=?');
--- 754,765 ----
    }
  
+ #xx1
    my $lookup_type = $dbh->prepare_delayed('SELECT ftypeid FROM ftype WHERE fmethod=? AND fsource=?');
    my $insert_type = $dbh->prepare_delayed('INSERT INTO ftype (fmethod,fsource) VALUES (?,?)');
  
    my $lookup_group = $dbh->prepare_delayed('SELECT feature_id FROM cmap_feature WHERE feature_name=? AND gclass=?');
!   my $insert_group = $dbh->prepare_delayed(' INSERT into cmap_feature (feature_id, accession_id,feature_name, gclass ) VALUES (?,feature_id,?,?)');
!   my $aux_insert_group = $dbh->prepare_delayed(' update cmap_next_number set next_number = next_number +1 where table_name=\'cmap_feature\'');
!   my $next_id_group = $dbh->prepare_delayed('select next_number from cmap_next_number where table_name=\'cmap_feature\'');
  
    my $lookup_attribute = $dbh->prepare_delayed('SELECT fattribute_id FROM fattribute WHERE fattribute_name=?');
***************
*** 773,778 ****
    $self->{load_stuff}{sth}{lookup_ftype}     = $lookup_type;
    $self->{load_stuff}{sth}{insert_ftype}     = $insert_type;
!   $self->{load_stuff}{sth}{lookup_fgroup}    = $lookup_group;
!   $self->{load_stuff}{sth}{insert_fgroup}    = $insert_group;
    $self->{load_stuff}{sth}{insert_fdata}     = $insert_data;
    $self->{load_stuff}{sth}{lookup_fattribute} = $lookup_attribute;
--- 777,786 ----
    $self->{load_stuff}{sth}{lookup_ftype}     = $lookup_type;
    $self->{load_stuff}{sth}{insert_ftype}     = $insert_type;
!   #$self->{load_stuff}{sth}{lookup_fgroup}    = $lookup_group;
!   #$self->{load_stuff}{sth}{insert_fgroup}    = $insert_group;
!   $self->{load_stuff}{sth}{lookup_cmap_feature}     = $lookup_group;
!   $self->{load_stuff}{sth}{insert_cmap_feature}     = $insert_group;
!   $self->{load_stuff}{sth}{aux_insert_cmap_feature} = $aux_insert_group;
!   $self->{load_stuff}{sth}{next_id_cmap_feature}   = $next_id_group;
    $self->{load_stuff}{sth}{insert_fdata}     = $insert_data;
    $self->{load_stuff}{sth}{lookup_fattribute} = $lookup_attribute;
***************
*** 887,890 ****
--- 895,974 ----
    return $fid;
  }
+ 
+ =head2 get_table_id
+ 
+  Title   : get_table_id
+  Usage   : $integer = $db->get_table_id($table, at ids)
+  Function: get the ID of a group or type
+  Returns : an integer ID or undef
+  Args    : none
+  Status  : private
+ 
+ This internal method is called by load_gff_line to look up the integer
+ ID of an existing feature type or group.  The arguments are the name
+ of the table, and two string identifiers.  For feature types, the
+ identifiers are the method and source.  For groups, the identifiers
+ are group name and class.
+ 
+ This method requires that a statement handler named I<lookup_$table>,
+ have been created previously by setup_load().  It is here to overcome
+ deficiencies in mysql's INSERT syntax.
+ 
+ =cut
+ 
+ #'
+ # get the object ID from a named table
+ sub get_table_id {
+   my $self   = shift;
+   my $table  = shift;
+   my @ids    = @_;
+ 
+   # irritating warning for null id
+   my $id_key;
+   {
+     local $^W=0;
+     $id_key = join ':', at ids;
+   }
+ 
+   my $s   = $self->{load_stuff};
+   my $sth = $s->{sth};
+   my $dbh = $self->features_db;
+ 
+   unless (defined($s->{$table}{$id_key})) {
+ 
+     #########################################
+     # retrieval of the last inserted id is now located at the adaptor and not in caching_handle
+     #######################################
+     if ( (my $result = $sth->{"lookup_$table"}->execute(@ids)) > 0) {
+       $s->{$table}{$id_key} = ($sth->{"lookup_$table"}->fetchrow_array)[0];
+     } else {
+       if (defined($sth->{"next_id_$table"})){
+ 
+         $sth->{"insert_$table"}->execute(3,'string1','string2');
+         # Can't use auto incrementing
+         $sth->{"next_id_$table"}->execute();
+         $s->{$table}{$id_key} = ($sth->{"next_id_$table"}->fetchrow_array)[0];
+         if ($s->{$table}{$id_key}){
+             $sth->{"insert_$table"}->execute($s->{$table}{$id_key}, at ids);
+             $sth->{"aux_insert_$table"}->execute() if $sth->{"aux_insert_$table"};
+         }
+       }
+       else{
+           $sth->{"insert_$table"}->execute(@ids);
+           $s->{$table}{$id_key} = $self->insertid($sth->{"insert_$table"}) unless $s->{$table}{$id_key};
+           $sth->{"aux_insert_$table"}->execute() if $sth->{"aux_insert_$table"};
+       }
+     }
+   }
+ 
+   my $id = $s->{$table}{$id_key};
+   unless (defined $id) {
+     warn "No $table id for $id_key ",$dbh->errstr," Record skipped.\n";
+     return;
+   }
+   $id;
+ }
+ 
+ 
  
  #-----------------------------------



More information about the Bioperl-guts-l mailing list