-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvariant_pull.sql
More file actions
64 lines (59 loc) · 1.7 KB
/
Copy pathvariant_pull.sql
File metadata and controls
64 lines (59 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-------------------------------------
-- COMMON TABLE EXPRESSIONS (CTEs) --
-------------------------------------
-- Extracts all variant hashes (VH; HA amino acid sequence variant) staged for HI and/or HINT antigenic testing by the "Referral System" (REFSYS) workflow
-- LEFT ANTI JOIN removes all VHs already processed by OpenFold3 and Rosetta v3.17
-- NOTE: Listed VHs represent ONLY seasonal subtypes: "B vic", "H1 swl", and "H3"
WITH STAGED_VARIANT_HASH AS (
SELECT
DISTINCT
SR.variant_hash
FROM
ref_sys.staged_recommendation AS SR
LEFT ANTI JOIN
protein_modeling.relaxed_rosetta_per_resi_energy AS RMSD_PRE ON SR.variant_hash = RMSD_PRE.variant_hash
),
-- Links staged VHs with computed "priority" score in the PROTEIN_MODELING.MODEL_PRIORITY CDP table
-- DENSE_RANK applied to re-order all extracted MODEL_PRIORITY metrics into ascending (ASC) numerical scale
-- NOTE: See MODEL_PRIORITY.SQL code for full DENSE_RANK parameters, metrics, and SQL logic
STAGED_PRIORITY AS (
SELECT
MP.subtype,
MP.variant_hash,
DENSE_RANK() OVER(
PARTITION BY
MP.subtype
ORDER BY
MP.model_priority ASC
) AS priority
FROM
STAGED_VARIANT_HASH AS SVH
INNER JOIN
protein_modeling.model_priority AS MP ON SVH.variant_hash = MP.variant_hash
)
----------------------
-- SELECT STATEMENT --
----------------------
SELECT
SP_B.variant_hash
FROM
STAGED_PRIORITY AS SP_B
WHERE
SP_B.subtype = 'B vic'
AND SP_B.priority <= 5
UNION
SELECT
SP_H1.variant_hash
FROM
STAGED_PRIORITY AS SP_H1
WHERE
SP_H1.subtype = 'H1 swl'
AND SP_H1.priority <= 10
UNION
SELECT
SP_H3.variant_hash
FROM
STAGED_PRIORITY AS SP_H3
WHERE
SP_H3.subtype = 'H3'
AND SP_H3.priority <= 15;