From 9b9668255f82efeefb7ac99add13aed4c80d03cf Mon Sep 17 00:00:00 2001
From: Magali Ruffier <mr6@ebi.ac.uk>
Date: Mon, 18 Feb 2013 14:01:28 +0000
Subject: [PATCH] added test module for ontology term

---
 modules/t/ontologyTerm.t | 58 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 modules/t/ontologyTerm.t

diff --git a/modules/t/ontologyTerm.t b/modules/t/ontologyTerm.t
new file mode 100644
index 0000000000..0774eb2350
--- /dev/null
+++ b/modules/t/ontologyTerm.t
@@ -0,0 +1,58 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+use Bio::EnsEMBL::Registry;
+use Bio::EnsEMBL::DBSQL::OntologyDBAdaptor;
+use Bio::EnsEMBL::Test::MultiTestDB;
+use Bio::EnsEMBL::Test::TestUtils;
+use Bio::EnsEMBL::Exon;
+use Bio::EnsEMBL::FeaturePair;
+use Bio::EnsEMBL::Transcript;
+use Bio::EnsEMBL::Translation;
+use Bio::EnsEMBL::Gene;
+use Bio::EnsEMBL::DnaDnaAlignFeature;
+
+# switch on the debug prints
+our $verbose = 0;
+
+debug("Startup test");
+ok(1);
+
+my $multi = Bio::EnsEMBL::Test::MultiTestDB->new('ontology');
+
+my $odb = $multi->get_DBAdaptor("ontology");
+debug("Ontology database instatiated");
+ok($odb);
+
+my $human = Bio::EnsEMBL::Test::MultiTestDB->new();
+my $db = $human->get_DBAdaptor("core");
+debug("Test database instatiated");
+ok($db);
+
+my $accession = "GO:0003677";
+my $go_adaptor = $odb->get_OntologyTermAdaptor();
+my $term = $go_adaptor->fetch_by_accession($accession);
+my $gene;
+my $ga = $db->get_GeneAdaptor();
+
+my $genes = $ga->fetch_all_by_GOTerm($term);
+is(@{$genes}, 2, "Genes match the GO term");
+
+my $pattern = '%binding%';
+my $terms = $go_adaptor->fetch_all_by_name($pattern);
+is(@{$terms}, 138, "Found binding terms");
+
+my $roots = $go_adaptor->fetch_all_roots();
+is(@{$roots}, 1, "Found roots");
+
+my $go_roots = $go_adaptor->fetch_all_roots('go');
+is(@{$go_roots}, 1, "Found go roots");
+
+my $efo_roots = $go_adaptor->fetch_all_roots('efo');
+is(@{$efo_roots}, 0, "Found no efo roots");
+
+
+
+done_testing();
-- 
GitLab