-
Notifications
You must be signed in to change notification settings - Fork 3
Issue 47265 - Data validation queries for dams and sires #667
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
|
|
||
| SELECT DISTINCT dam AS Id, | ||
| gender, | ||
| species | ||
| FROM demographics | ||
| WHERE dam IN (SELECT sire FROM demographics) | ||
|
|
||
| UNION | ||
|
|
||
| SELECT DISTINCT sire AS Id, | ||
| gender, | ||
| species | ||
| FROM demographics | ||
| WHERE sire IN (SELECT dam FROM demographics); |
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,20 @@ | ||
| SELECT * | ||
| FROM ( | ||
| SELECT | ||
| d1.Id, | ||
| d1.gender, | ||
| d1.species, | ||
| d2.Id as damId, | ||
| d2.species as damSpecies, | ||
| d3.Id as sireId, | ||
| d3.species as sireSpecies, | ||
| CASE WHEN (d2.species IS NOT NULL AND d1.species != d2.species) AND | ||
| (d3.species IS NOT NULL AND d1.species != d3.species) | ||
| THEN TRUE | ||
| ELSE FALSE | ||
| END as parentSpeciesMismatch | ||
| FROM demographics d1 | ||
| LEFT JOIN demographics d2 ON d1.dam = d2.Id | ||
| LEFT JOIN demographics d3 ON d1.sire = d3.Id | ||
| ) d4 | ||
| WHERE d4.parentSpeciesMismatch = TRUE |
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,20 @@ | ||
| SELECT * | ||
| FROM ( | ||
| SELECT | ||
| d1.Id, | ||
| d1.gender, | ||
| d1.species, | ||
| d2.Id as damId, | ||
| d2.gender as damGender, | ||
| d3.Id as sireId, | ||
| d3.gender as sireGender, | ||
| CASE WHEN (d2.gender IS NOT NULL AND d2.gender.meaning NOT IN ('FEMALE', 'UNKNOWN', 'UNDETERMINED')) OR | ||
| (d3.gender IS NOT NULL AND d3.gender.meaning NOT IN ('MALE', 'UNKNOWN', 'UNDETERMINED')) | ||
|
ankurjuneja marked this conversation as resolved.
Outdated
|
||
| THEN TRUE | ||
| ELSE FALSE | ||
| END as parentSpeciesMismatch | ||
| FROM demographics d1 | ||
| LEFT JOIN demographics d2 ON d1.dam = d2.Id | ||
| LEFT JOIN demographics d3 ON d1.sire = d3.Id | ||
| ) d4 | ||
| WHERE d4.parentSpeciesMismatch = TRUE | ||
16 changes: 16 additions & 0 deletions
16
ehr/resources/queries/study/parentsYoungerThanOffspring.sql
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,16 @@ | ||
| SELECT * | ||
| FROM ( | ||
| SELECT | ||
| dem.Id, | ||
| dem.gender, | ||
| dem.species, | ||
| dem.birth, | ||
| dem.dam, | ||
| damDem.birth as damBirth, | ||
| dem.sire, | ||
| sireDem.birth as sireBirth | ||
| FROM demographics dem | ||
| LEFT JOIN demographics damDem ON dem.dam = damDem.Id | ||
| LEFT JOIN demographics sireDem ON dem.sire = sireDem.Id | ||
| ) t | ||
| WHERE (t.birth <= t.damBirth OR t.birth <= t.sireBirth) |
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,37 @@ | ||
| <div id="incorrect-gender"></div> | ||
| <div id="incorrect-species"></div> | ||
| <div id="incorrect-ids"></div> | ||
| <div id="incorrect-age"></div> | ||
|
|
||
| <script type="text/javascript"> | ||
| Ext4.onReady(function (){ | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'incorrect-gender', | ||
| title: 'Parents having incorect gender', | ||
| schemaName: 'study', | ||
| queryName: 'parentsIncorrectGender', | ||
| }) | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'incorrect-species', | ||
| title: 'Parents having different species than offspring', | ||
| schemaName: 'study', | ||
| queryName: 'parentsDifferentSpecies', | ||
| }) | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'incorrect-ids', | ||
| title: 'Parents that are listed as both dam and sire', | ||
| schemaName: 'study', | ||
| queryName: 'animalIdsAsDamAndSire', | ||
| }) | ||
|
|
||
| new LABKEY.QueryWebPart({ | ||
| renderTo: 'incorrect-age', | ||
| title: 'Dam/Sire younger than offspring', | ||
| schemaName: 'study', | ||
| queryName: 'parentsYoungerThanOffspring', | ||
| }) | ||
| }); | ||
| </script> |
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.
Uh oh!
There was an error while loading. Please reload this page.