squash perl 5.12 warning
[bioperl-db.git] / t / 09fuzzy2.t
blob3d5a8a0844d4b72f9b8b321b0eea643cb01740d4
1 # -*-Perl-*-
2 # $Id$
4 BEGIN {
5     use lib 't';
6     use Bio::Root::Test;
7     test_begin(-tests => 23);
8 # -----------------------------------------------
9 # REQUIREMENTS TESTED: (not yet!)
10 # unknown start/end (eg like we find in SP)
11 # must be handled gracefully
12 # cjm@fruitfly.org
13 # -----------------------------------------------
14         use_ok('DBTestHarness');
15         use_ok('Bio::SeqIO');
18 $biosql = DBTestHarness->new("biosql");
19 $db = $biosql->get_DBAdaptor();
20 ok $db;
22 my $seqio = Bio::SeqIO->new('-format' => 'embl',
23                             '-file' => test_input_file('AB030700.embl'));
24 my $seq = $seqio->next_seq();
25 ok $seq;
26 my $pseq = $db->create_persistent($seq);
27 $pseq->namespace("mytestnamespace");
28 $pseq->create();
29 ok $pseq->primary_key();
31 my $seqadp = $db->get_object_adaptor($seq);
32 ok $seqadp;
34 eval {
35     my $sequk = Bio::Seq::RichSeq->new(-accession_number => "AB030700",
36                                        -version   => 1,
37                                        -namespace => "mytestnamespace");
38     $dbseq = $seqadp->find_by_unique_key($sequk);
39     ok $dbseq;
41     is ($dbseq->display_id, $seq->display_id);
42     is ($dbseq->accession, $seq->accession);
43     is ($dbseq->subseq(3,10), $seq->subseq(3,10) );
44     is ($dbseq->subseq(1,15), $seq->subseq(1,15) );
45     is ($dbseq->length, $seq->length);
46     is ($dbseq->seq, $seq->seq);
47     is ($dbseq->desc, $seq->desc);
49     @dblinks = sort {
50         $a->primary_id cmp $b->primary_id
51         } $dbseq->annotation->get_Annotations('dblink');
52     @stdlinks = sort {
53         $a->primary_id cmp $b->primary_id
54         } $seq->annotation->get_Annotations('dblink');
56     ok (scalar(@dblinks));
57     is (scalar(@dblinks), scalar(@stdlinks));
59     for(my $i = 0; $i < @dblinks; $i++) {
60         is($dblinks[$i]->database, $stdlinks[$i]->database);
61         is($dblinks[$i]->primary_id, $stdlinks[$i]->primary_id);
62         TODO: {
63                 local $TODO = 'optional_id() for dblinks is not working yet';
64                 is($dblinks[$i]->optional_id, $stdlinks[$i]->optional_id);
65         }
66     }
69 print STDERR $@ if $@;
71 # delete seq
72 is ($pseq->remove(), 1);
73 my $ns = Bio::DB::Persistent::BioNamespace->new(-identifiable => $pseq);
74 ok $ns = $db->get_object_adaptor($ns)->find_by_unique_key($ns);
75 ok $ns->primary_key();
76 is ($ns->remove(), 1);