diff --git a/scripts/clinvar-curartion/cvc-annotations-as-of-func.sql b/scripts/clinvar-curartion/cvc-annotations-as-of-func.sql index bd69222..305c4ca 100644 --- a/scripts/clinvar-curartion/cvc-annotations-as-of-func.sql +++ b/scripts/clinvar-curartion/cvc-annotations-as-of-func.sql @@ -13,6 +13,7 @@ WITH anno AS -- scv scv_id, scv_ver, + review_status, -- annotation assessment record curator, annotated_on, @@ -111,6 +112,7 @@ WITH anno AS -- scv a.scv_id, a.scv_ver, + a.review_status, -- annotation assessment record a.curator, a.annotated_on, diff --git a/scripts/clinvar-curartion/cvc-baseline-annotations-as-of-func.sql b/scripts/clinvar-curartion/cvc-baseline-annotations-as-of-func.sql index c1a3b7b..2f48391 100644 --- a/scripts/clinvar-curartion/cvc-baseline-annotations-as-of-func.sql +++ b/scripts/clinvar-curartion/cvc-baseline-annotations-as-of-func.sql @@ -19,7 +19,8 @@ WITH av.vcv_id, av.vcv_ver, av.is_latest, - av.annotation_label + av.annotation_label, + av FROM `clinvar_curator.cvc_annotations_view` av, `clinvar_ingest.schema_on`(as_of_date) rel WHERE @@ -107,6 +108,7 @@ WITH -- scv a.scv_id, a.scv_ver, + a.review_status, -- annotation assessment record a.curator, a.annotated_on, diff --git a/scripts/clinvar-curartion/cvc-submitter-annotations-as-of-func.sql b/scripts/clinvar-curartion/cvc-submitter-annotations-as-of-func.sql index 4a1dfb3..965fdf1 100644 --- a/scripts/clinvar-curartion/cvc-submitter-annotations-as-of-func.sql +++ b/scripts/clinvar-curartion/cvc-submitter-annotations-as-of-func.sql @@ -23,7 +23,17 @@ WITH (a.is_latest_annotation AND NOT a.is_deleted_scv) AND a.action="no change" AND a.is_outdated_scv - ) AS outdated_nochange_count + ) AS outdated_nochange_count, + COUNTIF( + (a.is_latest_annotation AND NOT a.is_deleted_scv) AND + (a.action="remove flagged submission" ) + ) AS remove_flagged_submission_count, + COUNTIF( + (a.is_latest_annotation AND NOT a.is_deleted_scv) AND + ( + a.action="remove flagged submission") AND + a.is_outdated_scv + ) AS outdated_remove_flagged_submission_count FROM `clinvar_curator.cvc_annotations_as_of`(as_of_date, true, true) a GROUP BY a.release_date, @@ -40,6 +50,8 @@ WITH x.outdated_flagging_candidate_count, x.nochange_count, x.outdated_nochange_count, + x.remove_flagged_submission_count, + x.outdated_remove_flagged_submission_count, MAX(scv.submission_date) as latest_submission_date, x.release_date, as_of_date @@ -64,6 +76,8 @@ WITH x.outdated_flagging_candidate_count, x.nochange_count, x.outdated_nochange_count, + x.remove_flagged_submission_count, + x.outdated_remove_flagged_submission_count, x.release_date, as_of_date ); \ No newline at end of file diff --git a/scripts/clinvar-curartion/cvc-submitter-annotations-func.sql b/scripts/clinvar-curartion/cvc-submitter-annotations-func.sql deleted file mode 100644 index 4a1dfb3..0000000 --- a/scripts/clinvar-curartion/cvc-submitter-annotations-func.sql +++ /dev/null @@ -1,69 +0,0 @@ -CREATE OR REPLACE TABLE FUNCTION `clinvar_curator.cvc_submitter_annotations_as_of`(as_of_date DATE) AS ( -WITH - x AS ( - SELECT - a.release_date, - as_of_date, - a.submitter_id, - COUNTIF( - (a.is_latest_annotation AND NOT a.is_deleted_scv) AND - (a.action="flagging candidate" ) - ) AS flagging_candidate_count, - COUNTIF( - (a.is_latest_annotation AND NOT a.is_deleted_scv) AND - ( - a.action="flagging candidate") AND - a.is_outdated_scv - ) AS outdated_flagging_candidate_count, - COUNTIF( - (a.is_latest_annotation AND NOT a.is_deleted_scv) AND - a.action="no change" - ) AS nochange_count, - COUNTIF( - (a.is_latest_annotation AND NOT a.is_deleted_scv) AND - a.action="no change" AND - a.is_outdated_scv - ) AS outdated_nochange_count - FROM `clinvar_curator.cvc_annotations_as_of`(as_of_date, true, true) a - GROUP BY - a.release_date, - as_of_date, - a.submitter_id ) - SELECT - s.id, - s.current_name, - s.current_abbrev, - s.cvc_abbrev, - COUNT(scv.id) AS submission_count, - COUNT(DISTINCT scv.variation_id) AS variation_count, - x.flagging_candidate_count, - x.outdated_flagging_candidate_count, - x.nochange_count, - x.outdated_nochange_count, - MAX(scv.submission_date) as latest_submission_date, - x.release_date, - as_of_date - FROM - x - JOIN - `clinvar_ingest.clinvar_submitters` s - ON - s.id = x.submitter_id AND - x.release_date BETWEEN S.start_release_date AND S.end_release_date - JOIN - `clinvar_ingest.clinvar_scvs` scv - ON - scv.submitter_id = s.id AND - x.release_date BETWEEN scv.start_release_date AND scv.end_release_date - GROUP BY - s.id, - s.current_name, - s.current_abbrev, - s.cvc_abbrev, - x.flagging_candidate_count, - x.outdated_flagging_candidate_count, - x.nochange_count, - x.outdated_nochange_count, - x.release_date, - as_of_date -); \ No newline at end of file