use
vars
qw($old_obda_path)
;
BEGIN {
plan
tests
=> 12;
$old_obda_path
=
$ENV
{OBDA_SEARCH_PATH}
if
defined
$ENV
{OBDA_SEARCH_PATH};
$ENV
{OBDA_SEARCH_PATH} =
't/data/'
;
}
my
$biosql
= DBTestHarness->new(
"biosql"
);
my
$db
=
$biosql
->get_DBAdaptor();
ok
$db
;
my
$registry_file
=
"t/data/seqdatabase.ini"
;
my
$obda_name
=
"mytestbiosql"
;
write_registry(
$registry_file
);
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"
);
$pseq
->store();
ok
$pseq
->primary_key();
$pseq
->commit;
eval
{
my
$registry
= Bio::DB::Registry->new;
ok
$registry
;
my
$biodb
=
$registry
->get_database(
$obda_name
);
ok
$biodb
;
my
$seq
=
$biodb
->get_Seq_by_acc(
'AB019558'
);
ok
$seq
->primary_id, 5456929;
$seq
=
$biodb
->get_Seq_by_id(5456929);
ok
$seq
->accession,
"AB019558"
;
$seq
=
$biodb
->get_Seq_by_version(
'AB019558.1'
);
ok
$seq
->primary_id, 5456929;
};
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);
$ns
->commit;
END {
unlink
$registry_file
if
(-e
$registry_file
);
$ENV
{OBDA_SEARCH_PATH} =
$old_obda_path
if
defined
$old_obda_path
;
}
sub
write_registry {
my
$file
=
shift
;
my
$c
=
$db
->dbcontext;
my
(
$host
,
$port
,
$dbname
,
$pass
,
$user
,
$driver
) =
(
$c
->host,
$c
->port,
$c
->dbname,
$c
->password,
$c
->username,
$c
->driver);
my
$text
= "VERSION=1.00
[
$obda_name
]
protocol=biosql
location=
$host
:
$port
dbname=
$dbname
passwd=
$pass
user=
$user
driver=
$driver
";
open
F,
">$file"
;
print
F
$text
;
close
F;
}