[Bioperl-l] Bio::DB::BioDB - insert failed. Dupllicate entry '' for key 2?

Jay Hannah jay at jays.net
Sat Mar 4 23:52:16 UTC 2006


Greetings --

I'm trying to load my bioperl-db database (mySQL on Linux). I seem to be able to load 1 sequence at a time, but whenever I try to load the 2nd sequence, if fails with the output below...


Here's my script:
---------------------------------------
#!/usr/bin/perl

use strict;
use Bio::SeqIO;
use Bio::DB::BioDB;

my $db = Bio::DB::BioDB->new(
        -database   => "biosql",
        -host       => 'localhost',
        -port       => 3306,
        -dbname     => 'VIRUS',
        -driver     => 'mysql',
        -user       => 'dbastola',
        -pass       => '-----------',
);

my $file = "/home/dbastola/genbankSequences/GBVRL/gbvrl_2006_Jan/GB_Sequences/gbvrl1.seq";
my $infile  = Bio::SeqIO->new(-file => $file,  -format => 'GenBank');

my $seq = $infile->next_seq();
my $species = $seq->species;
print join " | ", $species->classification;
print "\n";

my $pseq = $db->create_persistent($seq);
$pseq->create() or die "create failed";
$pseq->commit;
exit;
------------------------------------


Output:

$ perl j2.pl
Human adenovirus type 15 | Mastadenovirus | Adenoviridae | dsDNA viruses, no RNA stage | Viruses

-------------------- WARNING ---------------------
MSG: insert in Bio::DB::BioSQL::BioNamespaceAdaptor (driver) failed, values were ("","") FKs ()
Duplicate entry '' for key 2
---------------------------------------------------

------------- EXCEPTION  -------------
MSG: create: object (Bio::DB::Persistent::BioNamespace) failed to insert or to be found by unique key
STACK Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/perl5/site_perl/5.8.3/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:208
STACK Bio::DB::Persistent::PersistentObject::create /usr/lib/perl5/site_perl/5.8.3/Bio/DB/Persistent/PersistentObject.pm:245
STACK Bio::DB::BioSQL::BasePersistenceAdaptor::create /usr/lib/perl5/site_perl/5.8.3/Bio/DB/BioSQL/BasePersistenceAdaptor.pm:171
STACK Bio::DB::Persistent::PersistentObject::create /usr/lib/perl5/site_perl/5.8.3/Bio/DB/Persistent/PersistentObject.pm:245
STACK toplevel j2.pl:26

--------------------------------------


At this point I can see my first sequence loaded into mySQL. biodatabase and biosequence have stuff in them. e.g.:


mysql> select * from biodatabase;
+----------------+------+-----------+-------------+
| biodatabase_id | name | authority | description |
+----------------+------+-----------+-------------+
|             23 |      | NULL      | NULL        |
+----------------+------+-----------+-------------+
1 row in set (0.00 sec)



And I noticed that if I delete that sequence from the database, I can once again load it, and the number biodatabase_id (23) increments. 20, 21, 22, 23, etc.

I'm trying to end up with a loop something like this:

while (my $seq = $infile->next_seq()) {
   print "   " . $seq->display_id . "\n";
   my $adp = $db->get_object_adaptor($seq);
   my $lseq = $adp->find_by_unique_key($seq);
   if ($lseq) {
      print "Already loaded! Deleting.\n";
      print "   Primary key: " . $lseq->primary_key . "\n";
      $lseq->remove;
      $lseq->commit;
   } 
   print "Loading...\n";
   my $pseq = $db->create_persistent($seq);
   $pseq->create or die "create failed";
   $pseq->commit or die "commit failed";
   $adp->commit;  # ???
}

But I can't seem to get more than 1 to load. Ever.

Is the bioperl-db code not reading/incrementing the biodatabase_id correctly? Am I skipping a step that makes that increment occur? Am I messing up the PK/FK somehow?

phpMyAdmin says that the Next AutoIndex for the bioentry table is 24... So that's good?

Thanks,

j
Omaha Perl Mongers
http://omaha.pm.org




More information about the Bioperl-l mailing list