1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 54,
10 -requires_module => 'Graph::Directed');
12 use_ok('Bio::Ontology::Term');
13 use_ok('Bio::Ontology::TermFactory');
14 use_ok('Bio::Annotation::DBLink');
17 my $obj = Bio::Ontology::Term->new();
19 isa_ok $obj, "Bio::Ontology::TermI";
21 is( $obj->identifier( "0003947" ), "0003947" );
22 is( $obj->identifier(), "0003947" );
24 is( $obj->name( "N-acetylgalactosaminyltransferase" ), "N-acetylgalactosaminyltransferase" );
25 is( $obj->name(), "N-acetylgalactosaminyltransferase" );
27 is( $obj->definition( "Catalysis of ..." ), "Catalysis of ..." );
28 is( $obj->definition(), "Catalysis of ..." );
30 is( $obj->version( "666" ), "666" );
31 is( $obj->version(), "666" );
33 ok( $obj->ontology( "category 1 name" ) );
34 is( $obj->ontology()->name(), "category 1 name" );
36 my $ont = Bio::Ontology::Ontology->new();
37 ok( $ont->name( "category 2 name" ) );
39 ok( $obj->ontology( $ont ) );
40 is( $obj->ontology()->name(), "category 2 name" );
42 is( $obj->is_obsolete( 1 ), 1 );
43 is( $obj->is_obsolete(), 1 );
45 is( $obj->comment( "Consider the term ..." ), "Consider the term ..." );
46 is( $obj->comment(), "Consider the term ..." );
48 is( $obj->get_synonyms(), 0 );
50 $obj->add_synonym( ( "AA", "AB" ) );
51 my @al1 = $obj->get_synonyms();
52 is( scalar(@al1), 2 );
53 is( $al1[ 0 ], "AA" );
54 is( $al1[ 1 ], "AB" );
56 my @al2 = $obj->remove_synonyms();
57 is( $al2[ 0 ], "AA" );
58 is( $al2[ 1 ], "AB" );
60 is( $obj->get_synonyms(), 0 );
61 is( $obj->remove_synonyms(), 0 );
63 $obj->add_synonyms( ( "AA", "AB" ) );
65 is( $obj->identifier(undef), undef );
66 is( $obj->name(undef), undef );
67 is( $obj->definition(undef), undef );
68 is( $obj->is_obsolete(0), 0 );
69 is( $obj->comment(undef), undef );
72 $obj = Bio::Ontology::Term->new(
73 -identifier => "0016847",
74 -name => "1-aminocyclopropane-1-carboxylate synthase",
75 -definition => "Catalysis of ...",
81 Bio::Annotation::DBLink->new(-database => 'db1'),
82 Bio::Annotation::DBLink->new(-database => 'db2')
87 is( $obj->identifier(), "0016847" );
88 is( $obj->name(), "1-aminocyclopropane-1-carboxylate synthase" );
89 is( $obj->definition(), "Catalysis of ..." );
90 is( $obj->is_obsolete(), 0);
91 is( $obj->comment(), "X" );
92 is( $obj->version(), "6.6.6" );
93 is( $obj->ontology()->name(), "cat" );
94 is( scalar($obj->get_dbxrefs), 2);
95 is( scalar($obj->get_references), 0);
97 # test object factory for terms
98 my $fact = Bio::Ontology::TermFactory->new();
99 $obj = $fact->create_object(-name => "some ontology term");
100 isa_ok $obj, "Bio::Ontology::TermI";
101 is ($obj->name, "some ontology term");
103 $fact->type("Bio::Ontology::GOterm");
104 $obj = $fact->create_object(-name => "some ontology term",
105 -identifier => "GO:987654");
106 isa_ok $obj, "Bio::Ontology::TermI";
107 isa_ok $obj, "Bio::Ontology::GOterm";
108 is ($obj->name, "some ontology term");
109 is ($obj->identifier, "GO:987654");
111 $fact->type("Bio::Annotation::OntologyTerm");
112 $obj = $fact->create_object(-name => "some ontology term",
113 -identifier => "GO:987654",
114 -ontology => "nonsense");
115 isa_ok $obj, "Bio::Ontology::TermI";
116 isa_ok $obj, "Bio::AnnotationI";
117 is ($obj->name, "some ontology term");
118 is ($obj->identifier, "GO:987654");
119 is ($obj->tagname, "nonsense");