Skip to content

Commit

Permalink
Merge bdfa9cf into d835b91
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasmaurel committed Sep 5, 2018
2 parents d835b91 + bdfa9cf commit dfcf69f
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
65 changes: 65 additions & 0 deletions lib/Bio/EnsEMBL/DataCheck/Checks/SampleRegulatoryFeatureExists.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
=head1 LICENSE
Copyright [2018] 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::SampleRegulatoryFeatureExists;

use warnings;
use strict;

use Moose;
use Test::More;
use Bio::EnsEMBL::DataCheck::Test::DataCheck;
use Bio::EnsEMBL::DataCheck::Utils qw/sql_count/;

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

use constant {
NAME => 'SampleRegulatoryFeatureExists',
DESCRIPTION => 'Check if the current regulatory build has a sample regulatory feature',
GROUPS => ['funcgen_integrity', 'funcgen_Post_regulatory_build'],
DB_TYPES => ['funcgen'],
TABLES => ['regulatory_build','regulatory_feature'],
};

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

my $sql = q/
SELECT COUNT(name) FROM regulatory_build
WHERE is_current=1
/;

if (! sql_count($self->dba, $sql) ) {
return (1, 'The database has no regulatory build');
}
}

sub tests {
my ($self) = @_;
my $desc = "Current regulatory build has a sample regulatory feature";
my $sql = qq/
SELECT regulatory_build.name FROM
regulatory_build JOIN
regulatory_feature ON (regulatory_build.sample_regulatory_feature_id=regulatory_feature.regulatory_feature_id and regulatory_build.regulatory_build_id=regulatory_feature.regulatory_build_id)
WHERE regulatory_feature.stable_id is not null
/;
is_rows_nonzero($self->dba, $sql, $desc);
}

1;

10 changes: 10 additions & 0 deletions lib/Bio/EnsEMBL/DataCheck/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@
"name" : "PhenotypeDescription",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::PhenotypeDescription"
},
"SampleRegulatoryFeatureExists" : {
"datacheck_type" : "critical",
"description" : "Check if the current regulatory build has a sample regulatory feature",
"groups" : [
"funcgen_integrity",
"funcgen_Post_regulatory_build"
],
"name" : "SampleRegulatoryFeatureExists",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::SampleRegulatoryFeatureExists"
},
"SchemaVersion" : {
"datacheck_type" : "critical",
"description" : "Check that the schema version meta_key matches the DB name",
Expand Down

0 comments on commit dfcf69f

Please sign in to comment.