Skip to content
Snippets Groups Projects
Commit 82d77944 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Throw exceptions where appropriate.

parent b1153883
No related branches found
No related tags found
No related merge requests found
=head1 LICENSE
Copyright (c) 1999-2009 The European Bioinformatics Institute and
......@@ -52,6 +51,8 @@ use warnings;
use DBI qw( :sql_types );
use Bio::EnsEMBL::Utils::Argument qw( rearrange );
use Bio::EnsEMBL::Utils::Exception qw( throw );
use Bio::EnsEMBL::OntologyTerm;
use base qw( Bio::EnsEMBL::DBSQL::BaseAdaptor );
......@@ -80,6 +81,11 @@ use base qw( Bio::EnsEMBL::DBSQL::BaseAdaptor );
sub new {
my ( $proto, $dba, $ontology ) = @_;
if ( !ref($dba) || !$dba->isa('Bio::EnsEMBL::DBSQL::DBAdaptor') ) {
throw('First argument needs to be a '
. 'Bio::EnsEMBL::DBSQL::DBAdaptor object' );
}
my $this = $proto->SUPER::new($dba);
$this->{'ontology'} = $ontology;
......@@ -176,6 +182,10 @@ WHERE ontology.name = ?
sub fetch_by_parent_term {
my ( $this, $term ) = @_;
if ( !ref($term) || !$term->isa('Bio::EnsEMBL::OntologyTerm') ) {
throw('Argument needs to be a Bio::EnsEMBL::OntologyTerm object');
}
my @terms;
if ( !$term->{'child_terms_fetched'} ) {
......@@ -253,6 +263,10 @@ WHERE ontology.name = ?
sub fetch_all_by_parent_term {
my ( $this, $term ) = @_;
if ( !ref($term) || !$term->isa('Bio::EnsEMBL::OntologyTerm') ) {
throw('Argument needs to be a Bio::EnsEMBL::OntologyTerm object');
}
my $statement = q(
SELECT DISTINCT
child_term.term_id,
......@@ -316,6 +330,10 @@ ORDER BY closure.distance, child_term.accession);
sub fetch_by_child_term {
my ( $this, $term ) = @_;
if ( !ref($term) || !$term->isa('Bio::EnsEMBL::OntologyTerm') ) {
throw('Argument needs to be a Bio::EnsEMBL::OntologyTerm object');
}
my @terms;
if ( !$term->{'parent_terms_fetched'} ) {
......@@ -392,6 +410,10 @@ WHERE ontology.name = ?
sub fetch_all_by_child_term {
my ( $this, $term ) = @_;
if ( !ref($term) || !$term->isa('Bio::EnsEMBL::OntologyTerm') ) {
throw('Argument needs to be a Bio::EnsEMBL::OntologyTerm object');
}
my $statement = q(
SELECT DISTINCT
parent_term.term_id,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment