-
Notifications
You must be signed in to change notification settings - Fork 29
Fix/check beta sample location meta value #657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JackCurragh
wants to merge
4
commits into
release/mvp
Choose a base branch
from
fix/check_beta_sample_location_meta_value
base: release/mvp
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+127
−10
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7589ab0
check Beta meta key rather than main site beta key for sample gene di…
JackCurragh 51f73d1
Added set of DCs to validate genebuild.sample_location meta value
JackCurragh 90603f9
Update lib/Bio/EnsEMBL/DataCheck/Checks/DisplayableSampleLocation.pm
JackCurragh d05d993
Update lib/Bio/EnsEMBL/DataCheck/Checks/DisplayableSampleLocation.pm
JackCurragh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
lib/Bio/EnsEMBL/DataCheck/Checks/DisplayableSampleLocation.pm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| =head1 LICENSE | ||
|
|
||
| Copyright [2018-2025] 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::DisplayableSampleLocation; | ||
|
|
||
| use warnings; | ||
| use strict; | ||
|
|
||
| use Moose; | ||
| use Test::More; | ||
| use Bio::EnsEMBL::DataCheck::Test::DataCheck; | ||
|
|
||
| extends 'Bio::EnsEMBL::DataCheck::DbCheck'; | ||
|
|
||
| use constant { | ||
| NAME => 'DisplayableSampleLocation', | ||
| DESCRIPTION => 'Sample location is displayable and has web_data attached to its analysis', | ||
| GROUPS => ['analysis_description', 'core', 'geneset', 'meta_sample'], | ||
| DB_TYPES => ['core'], | ||
| TABLES => ['gene', 'meta', 'seq_region'] | ||
| }; | ||
|
|
||
| sub tests { | ||
| my ($self) = @_; | ||
|
|
||
| my $species_id = $self->dba->species_id; | ||
|
|
||
| my $desc_1 = 'Sample location metadata exists exactly once'; | ||
| my $diag_1 = 'genebuild.sample_location meta key should exist exactly once per species'; | ||
| my $sql_1 = qq/ | ||
| SELECT COUNT(*) AS count | ||
| FROM meta | ||
| WHERE meta_key = 'genebuild.sample_location' | ||
| AND species_id = $species_id | ||
| HAVING count != 1 | ||
| /; | ||
|
|
||
| is_rows_zero($self->dba, $sql_1, $desc_1, $diag_1); | ||
|
|
||
| my $desc_2 = 'Sample location metadata is valid format'; | ||
| my $diag_2 = 'genebuild.sample_location format is invalid'; | ||
| my $sql_2 = qq/ | ||
| SELECT meta_id | ||
| FROM meta | ||
| WHERE meta_key = 'genebuild.sample_location' | ||
| AND species_id = $species_id | ||
| AND meta_value NOT REGEXP '^.+:[0-9]+-[0-9]+\$' | ||
| /; | ||
|
|
||
| is_rows_zero($self->dba, $sql_2, $desc_2, $diag_2); | ||
|
|
||
| my $desc_3 = 'Sample location coordinates are properly ordered'; | ||
| my $diag_3 = 'genebuild.sample_location start coordinate is greater than end coordinate'; | ||
| my $sql_3 = qq/ | ||
| SELECT meta_id | ||
| FROM meta | ||
| WHERE meta_key = 'genebuild.sample_location' | ||
| AND species_id = $species_id | ||
| AND CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(meta_value, ':', -1), '-', 1) AS UNSIGNED) > | ||
| CAST(SUBSTRING_INDEX(meta_value, '-', -1) AS UNSIGNED) | ||
| /; | ||
|
|
||
| is_rows_zero($self->dba, $sql_3, $desc_3, $diag_3); | ||
|
|
||
| my $desc_4 = 'Sample location references valid seq_region'; | ||
| my $diag_4 = 'genebuild.sample_location seq_region does not exist or coordinates out of bounds'; | ||
| my $sql_4 = qq/ | ||
| SELECT m.meta_id | ||
| FROM meta m | ||
| LEFT JOIN seq_region sr | ||
| ON SUBSTRING_INDEX(m.meta_value, ':', 1) = sr.name | ||
| AND CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(m.meta_value, ':', -1), '-', 1) AS UNSIGNED) >= 1 | ||
| AND CAST(SUBSTRING_INDEX(m.meta_value, '-', -1) AS UNSIGNED) <= sr.length | ||
| WHERE m.meta_key = 'genebuild.sample_location' | ||
| AND m.species_id = $species_id | ||
| AND sr.seq_region_id IS NULL | ||
| /; | ||
|
|
||
| is_rows_zero($self->dba, $sql_4, $desc_4, $diag_4); | ||
|
|
||
| my $desc_5 = 'Sample location contains at least one gene'; | ||
| my $diag_5 = 'genebuild.sample_location region has no genes'; | ||
| my $sql_5 = qq/ | ||
| SELECT m.meta_id | ||
| FROM meta m | ||
| JOIN seq_region sr | ||
| ON SUBSTRING_INDEX(m.meta_value, ':', 1) = sr.name | ||
| LEFT JOIN gene g | ||
| ON g.seq_region_id = sr.seq_region_id | ||
| AND g.seq_region_start <= CAST(SUBSTRING_INDEX(m.meta_value, '-', -1) AS UNSIGNED) | ||
| AND g.seq_region_end >= CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(m.meta_value, ':', -1), '-', 1) AS UNSIGNED) | ||
| WHERE m.meta_key = 'genebuild.sample_location' | ||
| AND m.species_id = $species_id | ||
| AND g.gene_id IS NULL | ||
| /; | ||
|
|
||
| is_rows_zero($self->dba, $sql_5, $desc_5, $diag_5); | ||
|
|
||
| } | ||
|
|
||
| 1; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I'm not too familiar, worth asking: are we always choosing samples/coordinates from the "positive" strand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that even if the target feature is on reverse strand the the coordinates need to be in this order :-.
I basically just tried flipping them on one example location and the browser complained so I made it a DC.