BEGIN {
plan
tests
=> 48;
}
$biosql
= DBTestHarness->new(
"biosql"
);
$db
=
$biosql
->get_DBAdaptor();
ok
$db
;
my
$seqio
= Bio::SeqIO->new(
'-format'
=>
'genbank'
,
'-file'
=> Bio::Root::IO->catfile(
't'
,
'data'
,
'parkin.gb'
));
my
$seq
=
$seqio
->next_seq();
ok
$seq
;
my
$pseq
=
$db
->create_persistent(
$seq
);
$pseq
->namespace(
"mytestnamespace"
);
$feat
= Bio::SeqFeature::Generic->new;
$feat
->start(1);
$feat
->end(10);
$feat
->strand(-1);
$feat
->primary_tag(
'tag1'
);
$feat
->source_tag(
'some-source'
);
$feat
->add_tag_value(
'tag12'
,18);
$feat
->add_tag_value(
'tag12'
,
'another damn value'
);
$feat
->add_tag_value(
'another-tag'
,
'something else'
);
my
$pfeat
=
$db
->create_persistent(
$feat
);
ok
$pfeat
->isa(
"Bio::DB::PersistentObjectI"
);
$pseq
->create();
ok
$pseq
->primary_key();
$pfeat
->attach_seq(
$pseq
);
eval
{
$pfeat
->store();
ok
$pfeat
->primary_key();
$fadp
=
$db
->get_object_adaptor(
$feat
);
ok
$fadp
;
$dbf
=
$fadp
->find_by_primary_key(
$pfeat
->primary_key());
ok
$dbf
;
ok (
$dbf
->primary_key,
$pfeat
->primary_key);
ok (
$dbf
->primary_tag,
$feat
->primary_tag);
ok (
$dbf
->source_tag,
$feat
->source_tag);
ok (
$dbf
->location->start,
$feat
->location->start);
ok (
$dbf
->location->end,
$feat
->location->end);
ok (
$dbf
->location->strand,
$feat
->location->strand);
ok !
$dbf
->location->is_remote;
ok (
scalar
(
$dbf
->get_tag_values(
'tag12'
)), 2);
(
$value
) =
$dbf
->get_tag_values(
'another-tag'
);
ok(
$value
,
'something else'
);
$dbf
->add_tag_value(
'tag13'
,
'value for tag13'
);
$dbf
->attach_seq(
$pseq
);
ok
$dbf
->store();
my
$dbseq
=
$db
->get_object_adaptor(
"Bio::SeqI"
)->find_by_primary_key(
$pseq
->primary_key);
ok
$dbseq
;
(
$dbf
) =
grep
{
$_
->primary_tag eq
'tag1'
; }
$dbseq
->top_SeqFeatures();
ok
$dbf
;
ok (
scalar
(
$dbf
->get_tag_values(
'tag12'
)), 2);
(
$value
) =
$dbf
->get_tag_values(
'another-tag'
);
ok(
$value
,
'something else'
);
(
$value
) =
$dbf
->get_tag_values(
'tag13'
);
ok(
$value
,
'value for tag13'
);
ok (
$pfeat
->remove(), 1);
$pfeat
->location->is_remote(1);
$pfeat
->location->seq_id(
'AB123456'
);
$pfeat
->create();
$dbf
=
$fadp
->find_by_primary_key(
$pfeat
->primary_key());
ok
$dbf
;
ok (
$dbf
->primary_key,
$pfeat
->primary_key);
ok (
$dbf
->start, 1);
ok (
$dbf
->end, 10);
ok
$dbf
->location->is_remote;
ok (
$dbf
->location->seq_id,
"mytestnamespace:AB123456"
);
ok (
$pfeat
->remove(), 1);
$pfeat
->location->is_remote(1);
$pfeat
->location->seq_id(
'XZ:AB123456.4'
);
$pfeat
->create();
$dbf
=
$fadp
->find_by_primary_key(
$pfeat
->primary_key());
ok
$dbf
;
ok (
$dbf
->primary_key,
$pfeat
->primary_key);
ok (
$dbf
->start, 1);
ok (
$dbf
->end, 10);
ok
$dbf
->location->is_remote;
ok (
$dbf
->location->seq_id,
"XZ:AB123456.4"
);
ok (
$pseq
->remove, 1);
ok
$pfeat
->remove;
$pseq
->flush_SeqFeatures();
$pseq
->annotation->remove_Annotations();
$pseq
->add_SeqFeature(
$pfeat
);
ok
$pseq
->store;
$dbseq
=
$pseq
->adaptor->find_by_primary_key(
$pseq
->primary_key);
(
$dbf
) =
$dbseq
->top_SeqFeatures();
ok
$dbf
;
ok (
$dbf
->location->seq_id,
"XZ:AB123456.4"
);
$pfeat
->location->seq_id(
'AB123456'
);
ok
$pfeat
->store();
$dbseq
=
$pseq
->adaptor->find_by_primary_key(
$pseq
->primary_key);
(
$dbf
) =
$dbseq
->top_SeqFeatures();
ok
$dbf
;
ok (
$dbf
->location->seq_id,
"AB123456"
);
};
print
STDERR $@
if
$@;
ok (
$pseq
->remove(), 1);
my
$ns
= Bio::DB::Persistent::BioNamespace->new(
-identifiable
=>
$pseq
);
ok
$ns
=
$db
->get_object_adaptor(
$ns
)->find_by_unique_key(
$ns
);
ok
$ns
->primary_key();
ok (
$ns
->remove(), 1);