-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...rces/ManualTesting/MatchPredictionValidation/exercise4/SQL_Homework_ImputationResults.sql
This file contains 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,53 @@ | ||
/* | ||
* SELECT INFO BY PATIENT AND DONOR ID | ||
*/ | ||
DECLARE @PatientId varchar(16) = 'P000820' | ||
DECLARE @DonorId varchar(16) = 'D908661' | ||
|
||
-- select imputation summaries for patient and donor | ||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE ExternalSubjectId = @PatientId | ||
|
||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE ExternalSubjectId = @DonorId | ||
|
||
-- select distinct genotypes for patient | ||
SELECT DISTINCT | ||
Patient_A_1, Patient_A_2, | ||
Patient_B_1, Patient_B_2, | ||
Patient_C_1, Patient_C_2, | ||
Patient_DQB1_1, Patient_DQB1_2, | ||
Patient_DRB1_1, Patient_DRB1_2, | ||
Patient_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries p | ||
ON mg.Patient_ImputationSummary_Id = p.Id | ||
WHERE p.ExternalSubjectId = @PatientId | ||
|
||
-- select distinct genotypes for donors | ||
SELECT DISTINCT | ||
Donor_A_1, Donor_A_2, | ||
Donor_B_1, Donor_B_2, | ||
Donor_C_1, Donor_C_2, | ||
Donor_DQB1_1, Donor_DQB1_2, | ||
Donor_DRB1_1, Donor_DRB1_2, | ||
Donor_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries d | ||
ON mg.Donor_ImputationSummary_Id = d.Id | ||
WHERE d.ExternalSubjectId = @DonorId | ||
|
||
-- select matching genotypes | ||
SELECT mg.* | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries p | ||
ON mg.Patient_ImputationSummary_Id = p.Id | ||
JOIN ImputationSummaries d | ||
ON mg.Donor_ImputationSummary_Id = d.Id | ||
WHERE p.ExternalSubjectId = @PatientId and d.ExternalSubjectId = @DonorId |
53 changes: 53 additions & 0 deletions
53
...anualTesting/MatchPredictionValidation/exercise4/SQL_Homework_SelectMatchingGenotypes.sql
This file contains 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,53 @@ | ||
/* | ||
* SELECT INFO BY PATIENT AND DONOR ID | ||
*/ | ||
DECLARE @PatientId varchar(16) = 'P000820' | ||
DECLARE @DonorId varchar(16) = 'D448673' | ||
|
||
-- select imputation summaries for patient and donor | ||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
RIGHT JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE ExternalId = @PatientId | ||
|
||
SELECT si.*, i.* | ||
FROM ImputationSummaries i | ||
RIGHT JOIN SubjectInfo si | ||
ON i.ExternalSubjectId = si.ExternalId | ||
WHERE ExternalId = @DonorId | ||
|
||
-- select distinct genotypes for patient | ||
SELECT DISTINCT | ||
Patient_A_1, Patient_A_2, | ||
Patient_B_1, Patient_B_2, | ||
Patient_C_1, Patient_C_2, | ||
Patient_DQB1_1, Patient_DQB1_2, | ||
Patient_DRB1_1, Patient_DRB1_2, | ||
Patient_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries p | ||
ON mg.Patient_ImputationSummary_Id = p.Id | ||
WHERE p.ExternalSubjectId = @PatientId | ||
|
||
-- select distinct genotypes for donors | ||
SELECT DISTINCT | ||
Donor_A_1, Donor_A_2, | ||
Donor_B_1, Donor_B_2, | ||
Donor_C_1, Donor_C_2, | ||
Donor_DQB1_1, Donor_DQB1_2, | ||
Donor_DRB1_1, Donor_DRB1_2, | ||
Donor_Likelihood | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries d | ||
ON mg.Donor_ImputationSummary_Id = d.Id | ||
WHERE d.ExternalSubjectId = @DonorId | ||
|
||
-- select matching genotypes | ||
SELECT mg.* | ||
FROM MatchingGenotypes mg | ||
JOIN ImputationSummaries p | ||
ON mg.Patient_ImputationSummary_Id = p.Id | ||
JOIN ImputationSummaries d | ||
ON mg.Donor_ImputationSummary_Id = d.Id | ||
WHERE p.ExternalSubjectId = @PatientId and d.ExternalSubjectId = @DonorId |