Skip to content

Commit

Permalink
Merge pull request #385 from Ensembl/bugfix/ont_advisory
Browse files Browse the repository at this point in the history
Make ontology term comparisons advisory.
  • Loading branch information
james-monkeyshines committed Jul 1, 2021
2 parents 783f0bc + 32181d9 commit 49470d0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 12 deletions.
14 changes: 6 additions & 8 deletions lib/Bio/EnsEMBL/DataCheck/Checks/CheckOntologyTerm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ use constant {
sub tests {
my ($self) = @_;

my $desc = 'Critical terms are present in term table';
my @critical_terms = (
"'EFO:0003900'"
);
my $len = @critical_terms;
my @critical_terms = qw/EFO:0003900/;

my $sql = "SELECT COUNT(*) FROM term WHERE accession IN (".join(', ', @critical_terms).")";

is_rows($self->dba, $sql, $len, $desc);
foreach (@critical_terms) {
my $desc = "Critical term $_ is present in term table";
my $sql = "SELECT accession FROM term WHERE accession = '$_'";
is_rows($self->dba, $sql, 1, $desc);
}
}

1;
Expand Down
4 changes: 2 additions & 2 deletions lib/Bio/EnsEMBL/DataCheck/Checks/CompareOntologyTerm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ extends 'Bio::EnsEMBL::DataCheck::DbCheck';

use constant {
NAME => 'CompareOntologyTerm',
DESCRIPTION => 'Compare Term counts between current and previous ontology database',
DESCRIPTION => 'Compare namespace counts between current and previous ontology database',
GROUPS => ['ontologies'],
DATACHECK_TYPE => 'critical',
DATACHECK_TYPE => 'advisory',
DB_TYPES => ['ontology'],
TABLES => ['ontology', 'term']
};
Expand Down
58 changes: 58 additions & 0 deletions lib/Bio/EnsEMBL/DataCheck/Checks/CompareOntologyTotal.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
=head1 LICENSE
Copyright [2018-2021] EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an 'AS IS' BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut

package Bio::EnsEMBL::DataCheck::Checks::CompareOntologyTotal;

use warnings;
use strict;

use Moose;
use Test::More;
use Bio::EnsEMBL::DataCheck::Test::DataCheck;

extends 'Bio::EnsEMBL::DataCheck::DbCheck';

use constant {
NAME => 'CompareOntologyTotal',
DESCRIPTION => 'Compare total counts between current and previous ontology database',
GROUPS => ['ontologies'],
DATACHECK_TYPE => 'critical',
DB_TYPES => ['ontology'],
TABLES => ['ontology', 'term']
};

sub tests {
my ($self) = @_;

# Inherited code from DbCheck will always fail if the previous
# release's database cannot be found - so don't need to test
# for that here.
my $old_dba = $self->get_old_dba();

my $desc = 'Ontology term totals have not decreased in '.
$self->dba->dbc->dbname.' compared to '.$old_dba->dbc->dbname;
my $sql = q/
SELECT ontology.name, COUNT(*) FROM
term INNER JOIN
ontology USING (ontology_id)
GROUP BY ontology.name
/;
row_subtotals($self->dba, $old_dba, $sql, undef, 1.00, $desc);
}

1;
13 changes: 11 additions & 2 deletions lib/Bio/EnsEMBL/DataCheck/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,23 @@
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::CompareMetaKeys"
},
"CompareOntologyTerm" : {
"datacheck_type" : "critical",
"description" : "Compare Term counts between current and previous ontology database",
"datacheck_type" : "advisory",
"description" : "Compare namespace counts between current and previous ontology database",
"groups" : [
"ontologies"
],
"name" : "CompareOntologyTerm",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::CompareOntologyTerm"
},
"CompareOntologyTotal" : {
"datacheck_type" : "critical",
"description" : "Compare total counts between current and previous ontology database",
"groups" : [
"ontologies"
],
"name" : "CompareOntologyTotal",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::CompareOntologyTotal"
},
"ComparePhenotypeFeatures" : {
"datacheck_type" : "advisory",
"description" : "Compare phenotype feature counts between two databases, categorised by source",
Expand Down

0 comments on commit 49470d0

Please sign in to comment.