Skip to content

Commit

Permalink
Merge pull request #133 from Ensembl/stable_id_display_xref
Browse files Browse the repository at this point in the history
Stable id display xref
  • Loading branch information
james-monkeyshines committed Sep 4, 2019
2 parents 9ffcd57 + 1a81067 commit 14f4bef
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
62 changes: 62 additions & 0 deletions lib/Bio/EnsEMBL/DataCheck/Checks/StableIdDisplayXref.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
=head1 LICENSE
Copyright [2018-2019] 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::StableIdDisplayXref;

use warnings;
use strict;

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

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

use constant {
NAME => 'StableIdDisplayXref',
DESCRIPTION => 'Genes/Transcript display_xref does not have display_label set as stable_id',
GROUPS => ['xref'],
DB_TYPES => ['core'],
TABLES => ['gene','transcript','xref']
};

sub tests {
my ($self) = @_;
$self->check_display_xref('gene');
$self->check_display_xref('transcript');
}

sub check_display_xref {
my ($self, $table) = @_;
my $species_id = $self->dba->species_id;
my $desc = "No $table found with stable_id set as display_xrefs";
my $diag = "$table found with stable_id set as display_xrefs";
my $sql = qq/
SELECT stable_id FROM
$table tb JOIN
xref x on (tb.display_xref_id=x.xref_id) JOIN
seq_region sr USING (seq_region_id) INNER JOIN
coord_system cs USING (coord_system_id)
WHERE x.display_label=tb.stable_id AND
cs.species_id = $species_id
/;

is_rows_zero($self->dba, $sql, $desc, $diag);
}

1;
9 changes: 9 additions & 0 deletions lib/Bio/EnsEMBL/DataCheck/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,15 @@
"name" : "StableIDUnique",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::StableIDUnique"
},
"StableIdDisplayXref" : {
"datacheck_type" : "critical",
"description" : "Genes/Transcript display_xref does not have display_label set as stable_id",
"groups" : [
"xref"
],
"name" : "StableIdDisplayXref",
"package_name" : "Bio::EnsEMBL::DataCheck::Checks::StableIdDisplayXref"
},
"StructuralVariationFeature" : {
"datacheck_type" : "critical",
"description" : "StructuralVariationFeature table data is present and correct",
Expand Down

0 comments on commit 14f4bef

Please sign in to comment.