my
$error
;
use
lib
'..'
,
'.'
,
'./blib/lib'
;
use
vars
qw($NUMTESTS $DEBUG $HAVEGRAPHDIRECTED $errmsg)
;
$DEBUG
=
$ENV
{
'BIOPERLDEBUG'
} || 0;
BEGIN {
$errmsg
=
'Unable to run Interpro Tests'
;
$error
= 0;
if
( $@ ) {
}
$NUMTESTS
= 47;
plan
tests
=>
$NUMTESTS
;
eval
{
};
if
( $@ ) {
warn
(
"XML::Parser::PerlSAX not installed. This means that InterPro Ontology Parsing module is not usable. Skipping tests.\n"
)
if
$DEBUG
;
$errmsg
.=
', XML::Parser::PerlSAX not installed'
;
$error
= 1;
}
eval
{
};
if
( $@ ) {
warn
"XML::Parser not installed. This means that InterPro Ontology Parsing module is not usable. Skipping tests.\n"
if
$DEBUG
;
$error
= 1;
$errmsg
.=
', XML::Parser not installed'
;
}
$HAVEGRAPHDIRECTED
=1;
};
if
($@) {
$errmsg
.=
', Graph::Directed not installed'
;
$HAVEGRAPHDIRECTED
= 0;
$error
= 1;
}
}
END {
foreach
(
$Test::ntest
..
$NUMTESTS
) {
skip(
$errmsg
,1);
}
}
if
(
$error
) {
exit
(0);
}
my
$io
= Bio::Root::IO->new();
ok (1);
my
$ipp
= Bio::OntologyIO->new(
-format
=>
'interpro'
,
-file
=>
$io
->catfile(
't'
,
'data'
,
'interpro_short.xml'
),
-ontology_engine
=>
'simple'
);
ok (
$ipp
);
my
$ip
;
while
(
my
$ont
=
$ipp
->next_ontology()) {
ok (
$ip
,
undef
);
$ip
=
$ont
;
}
my
@rt
=
sort
{
$a
->name cmp
$b
->name; }
$ip
->get_root_terms();
ok (
scalar
(
@rt
), 6);
foreach
(
$ip
->get_leaf_terms,
@rt
) {
ok (
$_
->ontology);
ok (
$_
->ontology->name,
"InterPro"
,
"term "
.
$_
->name.
" not in ontology InterPro"
);
}
ok (
scalar
(
$ip
->get_leaf_terms()), 8);
ok (
scalar
(
$ip
->get_all_terms()), 13);
ok (
scalar
(
$ip
->get_descendant_terms(
$rt
[2])), 4);
ok (
scalar
(
$ip
->get_child_terms(
$rt
[2])), 4);
ok (
scalar
(
$ip
->get_descendant_terms(
$rt
[3])), 3);
ok (
scalar
(
$ip
->get_child_terms(
$rt
[3])), 3);
foreach
my
$t
(
$ip
->get_leaf_terms) {
if
(!(
$t
->identifier eq
"Repeat"
||
$t
->identifier eq
"PTM"
||
$t
->identifier eq
'Active_site'
||
$t
->identifier eq
'Binding_site'
)) {
ok (
scalar
(
$ip
->get_parent_terms(
$t
)), 1);
ok (
scalar
(
$ip
->get_ancestor_terms(
$t
)), 1);
}
}
ok(
scalar
(
keys
%{
$ipp
->secondary_accessions_map}), 2);