7 test_begin(-tests => 21);
8 use_ok('DBTestHarness');
10 use_ok('Bio::DB::Persistent::BioNamespace');
13 $biosql = DBTestHarness->new("biosql");
14 $db = $biosql->get_DBAdaptor();
17 my $seqio = Bio::SeqIO->new('-format' => 'genbank',
18 '-file' => test_input_file('parkin.gb'));
19 my $seq = $seqio->next_seq();
21 my $pseq = $db->create_persistent($seq);
22 $pseq->namespace("mytestnamespace");
24 ok $pseq->primary_key();
26 my $dbl = Bio::Annotation::DBLink->new();
27 $dbl->database("new-db");
28 $dbl->primary_id("primary-id-12");
32 my $pdbl = $db->create_persistent($dbl);
34 ok $pdbl->primary_key();
36 my $dbladp = $db->get_object_adaptor("Bio::Annotation::DBLink");
37 my $fromdb = $dbladp->find_by_primary_key($pdbl->primary_key());
39 is ($fromdb->primary_key, $pdbl->primary_key);
40 is ($fromdb->database, $dbl->database);
41 is ($fromdb->primary_id, $dbl->primary_id);
43 ok $dbladp->add_association(-objs => [$pseq, $pdbl]);
45 my $dbseq = $pseq->adaptor()->find_by_primary_key($pseq->primary_key());
48 $_->database() eq "new-db";
49 } $dbseq->annotation->get_Annotations("dblink");
50 is (scalar(@mydbls), 1);
51 is ($mydbls[0]->primary_id, $dbl->primary_id);
52 is ($mydbls[0]->primary_key, $pdbl->primary_key);
54 is ($fromdb->remove(), 1);
57 print STDERR $@ if $@;
60 is ($pseq->remove(), 1);
61 my $ns = Bio::DB::Persistent::BioNamespace->new(-identifiable => $pseq);
62 ok $ns = $db->get_object_adaptor($ns)->find_by_unique_key($ns);
63 ok $ns->primary_key();
64 is ($ns->remove(), 1);